apple / apple/swift-nio-examples

http2-client fatally fails when connection is refused

Open
#71 2 comments 0 reactions 0 assignees View on GitHub
good first issue
Dominant language
Swift
Stars
256
Forks
67
PR merge metrics
No merged PRs in 30d

Description

### Expected behavior
Error about connection being refused, no fatal error.

### Actual behavior
```
ERROR: NIOConnectionError(host: "localhost", port: 443, dnsAError: nil, dnsAAAAError: nil, connectionErrors: [NIO.SingleConnectionFailure(target: [IPv6]localhost/::1:443, error: connection reset (error set): Connection refused (errno: 61)), NIO.SingleConnectionFailure(target: [IPv4]localhost/127.0.0.1:443, error: connection reset (error set): Connection refused (errno: 61))])
Fatal error: leaking promise created at (file: "/Users/lauri/Documents/swift-nio-examples/http2-client/Sources/http2-client/main.swift", line: 298): file /Users/lauri/Documents/swift-nio-examples/http2-client/Sources/http2-client/main.swift, line 298
zsh: illegal hardware instruction swift run http2-client https://localhost/
```

### Steps to reproduce

1. Do not have any server running at localhost:443
2. Run `swift run http2-client https://localhost/`

### If possible, minimal yet complete reproducer code (or URL to code)

_[anything to help us reproducing the issue]_

### version/commit hashes from all involved dependencies

61a502f665c4217f5dfe163341e53a683e18a715

### Swift & OS version (output of `swift --version && uname -a`)
Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28)
Target: x86_64-apple-darwin19.6.0
Darwin MiniII.lan 19.6.0 Darwin Kernel Version 19.6.0: Tue Jun 22 19:49:55 PDT 2021; root:xnu-6153.141.35~1/RELEASE_X86_64 x86_64

Contributor guide

Open the contributing guide

Research direction

Start with Sources/http2-client/main.swift around line 298 and reproduce with `swift run http2-client https://localhost/` while no server listens on localhost:443. Trace the refused-connection failure and the promise created there; done means the client reports the connection refusal without a fatal error or leaked-promise crash.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
cli, networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.