websockets-rs / websockets-rs/rust-websocket
TlsHandshakeFailure
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.6k
- Forks
- 225
- PR merge metrics
- No merged PRs in 30d
Description
Hello, i have an error when connecting to a secure websocket (url: wss://gateway.discord.gg)
Error:
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Other(TlsHandshakeFailure)', src/workers/ws.rs:45:14
I declare the client with
let client = ClientBuilder::new(&*url)
.unwrap()
.connect(None)
.unwrap();
It seems like connecting to a wss throw this error.
Perhaps, when i try using "ws://echo.websocket.org", i get:
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Other(StatusCodeError(Ok))', src/workers/ws.rs:47:14
(trace:)
2023-05-20T12:40:45.599 [DEBUG] Connecting to ws://echo.websocket.org
2023-05-20T12:40:45.778 [TRACE] Headers.set( "Host", Host { hostname: "echo.websocket.org", port: None } )
2023-05-20T12:40:45.778 [TRACE] Headers.set( "Connection", Connection([ConnectionHeader(UniCase("Upgrade"))]) )
2023-05-20T12:40:45.778 [TRACE] Headers.set( "Upgrade", Upgrade([Protocol { name: WebSocket, version: None }]) )
2023-05-20T12:40:45.778 [TRACE] Headers.set( "Sec-WebSocket-Version", 13 )
2023-05-20T12:40:45.778 [TRACE] Headers.set( "Sec-WebSocket-Key", WebSocketKey(6v8eRHPaNOtWbexb1RRQtg==) )
2023-05-20T12:40:45.778 [TRACE] get_buf []
2023-05-20T12:40:45.778 [TRACE] read_into_buf buf[0..4096]
2023-05-20T12:40:45.911 [TRACE] get_buf [u8; 4096][0..354]
2023-05-20T12:40:45.911 [TRACE] try_parse([72, 84, 84, 80, 47, 49, 46, 49, 32, 50, 48, 48, 32, 79, 75, 13, 10, 120, 45, 97, 109, 122, 45, 105, 100, 45, 50, 58, 32, 115, 77, 68, 100, 77, 79, 57, 117, 56, 76, 118, 112, 121, 77, 99, 76, 67, 84, 83, 76, 56, 74, 105, 77, 50, 86, 77, 54, 88, 121, 84, 55, 83, 47, 97, 87, 56, 71, 89, 82, 118, 54, 103, 68, 67, 109, 76, 80, 114, 69, 78, 113, 70, 120, 56, 70, 80, 57, 54, 73, 43, 105, 110, 109, 66, 120, 104, 112, 54, 56, 119, 98, 77, 85, 99, 61, 13, 10, 120, 45, 97, 109, 122, 45, 114, 101, 113, 117, 101, 115, 116, 45, 105, 100, 58, 32, 52, 55, 81, 86, 68, 80, 71, 87, 56, 71, 86, 72, 75, 53, 88, 69, 13, 10, 68, 97, 116, 101, 58, 32, 83, 97, 116, 44, 32, 50, 48, 32, 77, 97, 121, 32, 50, 48, 50, 51, 32, 49, 50, 58, 52, 48, 58, 52, 54, 32, 71, 77, 84, 13, 10, 76, 97, 115, 116, 45, 77, 111, 100, 105, 102, 105, 101, 100, 58, 32, 84, 104, 117, 44, 32, 50, 54, 32, 65, 117, 103, 32, 50, 48, 50, 49, 32, 48, 51, 58, 51, 53, 58, 52, 50, 32, 71, 77, 84, 13, 10, 69, 84, 97, 103, 58, 32, 34, 54, 100, 53, 97, 50, 56, 102, 52, 99, 53, 101, 50, 57, 55, 101, 57, 53, 97, 50, 57, 57, 56, 56, 56, 56, 52, 99, 57, 101, 56, 57, 54, 34, 13, 10, 67, 111, 110, 116, 101, 110, 116, 45, 84, 121, 112, 101, 58, 32, 116, 101, 120, 116, 47, 104, 116, 109, 108, 13, 10, 83, 101, 114, 118, 101, 114, 58, 32, 65, 109, 97, 122, 111, 110, 83, 51, 13, 10, 67, 111, 110, 116, 101, 110, 116, 45, 76, 101, 110, 103, 116, 104, 58, 32, 52, 52, 49, 51, 13, 10, 67, 111, 110, 110, 101, 99, 116, 105, 111, 110, 58, 32, 99, 108, 111, 115, 101, 13, 10, 13, 10])
2023-05-20T12:40:45.911 [TRACE] Response.try_parse([Header; 100], [u8; 354])
2023-05-20T12:40:45.912 [TRACE] Response.try_parse Complete(354)
2023-05-20T12:40:45.912 [TRACE] raw header: "x-amz-id-2"=[115, 77, 68, 100, 77, 79, 57, 117, 56, 76, 118, 112, 121, 77, 99, 76, 67, 84, 83, 76, 56, 74, 105, 77, 50, 86, 77, 54, 88, 121, 84, 55, 83, 47, 97, 87, 56, 71, 89, 82, 118, 54, 103, 68, 67, 109, 76, 80, 114, 69, 78, 113, 70, 120, 56, 70, 80, 57, 54, 73, 43, 105, 110, 109, 66, 120, 104, 112, 54, 56, 119, 98, 77, 85, 99, 61]
2023-05-20T12:40:45.912 [TRACE] raw header: "x-amz-request-id"=[52, 55, 81, 86, 68, 80, 71, 87, 56, 71, 86, 72, 75, 53, 88, 69]
2023-05-20T12:40:45.912 [TRACE] raw header: "Date"=[83, 97, 116, 44, 32, 50, 48, 32, 77, 97, 121, 32, 50, 48, 50, 51, 32, 49, 50, 58, 52, 48, 58, 52, 54, 32, 71, 77, 84]
2023-05-20T12:40:45.912 [TRACE] raw header: "Last-Modified"=[84, 104, 117, 44, 32, 50, 54, 32, 65, 117, 103, 32, 50, 48, 50, 49, 32, 48, 51, 58, 51, 53, 58, 52, 50, 32, 71, 77, 84]
2023-05-20T12:40:45.912 [TRACE] raw header: "ETag"=[34, 54, 100, 53, 97, 50, 56, 102, 52, 99, 53, 101, 50, 57, 55, 101, 57, 53, 97, 50, 57, 57, 56, 56, 56, 56, 52, 99, 57, 101, 56, 57, 54, 34]
2023-05-20T12:40:45.912 [TRACE] raw header: "Content-Type"=[116, 101, 120, 116, 47, 104, 116, 109, 108]
2023-05-20T12:40:45.912 [TRACE] raw header: "Server"=[65, 109, 97, 122, 111, 110, 83, 51]
2023-05-20T12:40:45.912 [TRACE] raw header: "Content-Length"=[52, 52, 49, 51]
2023-05-20T12:40:45.912 [TRACE] raw header: "Connection"=[99, 108, 111, 115, 101]
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Other(StatusCodeError(Ok))', src/workers/ws.rs:47:14
But the websocket doesn't initialize itself when connecting to a wss
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with src/workers/ws.rs at lines 45-47 and reproduce the reported connections using the ClientBuilder example. Compare the wss://gateway.discord.gg and ws://echo.websocket.org outcomes, then trace the handshake and response handling. Done means the connection behavior is understood and the reported errors are handled or resolved without the shown panics.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100