Skip to content

AHC causes uncleanShutdown error on server side. #808

Open
@toffaletti

Description

@toffaletti

I have a server that is functionally similar in setup to hummingbird-examples/http2, when I use async-http-client to make a request with a command line program that exits after the request, humming bird reports this error:

[HummingbirdHTTP2] Error handling inbound connection for HTTP2 handler: uncleanShutdown

I do not see the same error when using curl:

curl --cacert certs/ca.crt --http2 -v https://localhost:8043/healthcheck
    var tlsConfiguration: TLSConfiguration {
        get throws {
            let certificateChain = try NIOSSLCertificate.fromPEMFile(self.certificateChain)
            var tlsConfiguration = TLSConfiguration.makeClientConfiguration()
            tlsConfiguration.trustRoots = .certificates(certificateChain)
            #if os(macOS)
            tlsConfiguration.certificateVerification = .none
            #else
            // not supported with Network.framework
            tlsConfiguration.certificateVerification = .noHostnameVerification
            #endif
            return tlsConfiguration
        }
    }

relevant code in the run() async throws method of an AsyncParsableCommand:

        var clientConfig = HTTPClient.Configuration()
        clientConfig.tlsConfiguration = try self.tlsConfiguration
        try await HTTPClient.withHTTPClient(configuration: clientConfig) { client in
            var request = HTTPClientRequest(url: url.absoluteString)
            request.method = .POST
            request.headers.add(name: "content-type", value: "application/json")
            request.headers.add(name: "content-length", value: "\(payloadData.count)")
            request.body = .bytes(payloadData)
            let response = try await client.execute(request, timeout: .seconds(30))
            let body = try await response.body.collect(upTo: 10 * 1024 * 1024)
        }

I've tried many variations that all execute await client.shutdown() before exiting and they all result in this error. From what Cory says here: https://forums.swift.org/t/niossl-spurious-uncleanshutdown-error/53031/3 it seems like AHC isn't sending CLOSE_NOTIFY on shutdown?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions