Skip to content

Connection refused not throwing right away #743

Closed
@andreasley

Description

@andreasley

AsyncHTTPClient commit hash: a220837 (Release 1.21.1)

While trying to use HTTPClientRequest on macOS (with NIOTransportServices), I noticed that refused connection errors are only thrown when the connection timeout expires.
With the following code, it takes 90 seconds (the connection timeout specified in HTTPClient.Configuration.singletonConfiguration) until the error is thrown:

import AsyncHTTPClient

var request = HTTPClientRequest(url: "https://localhost:12345/")
let response = try await HTTPClient.shared.execute(request, timeout: .hours(1))

I'd consider a refused connection a non-recoverable error and would expect execute to throw right away.

  • Is awaiting the timeout expected behavior here?
  • Is there a way to not wait in this situation while using HTTPClientRequest?

Environment:
$ swift --version
swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: arm64-apple-macosx14.0

Operating system: macOS Sonoma 14.5 (23F79)

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