[GH-ISSUE #51] Erroe: failed to write to incoming websocket: ConnectionClosed #43

Open
opened 2026-03-02 23:01:58 +03:00 by kerem · 11 comments
Owner

Originally created by @wnz99 on GitHub (Jun 4, 2021).
Original GitHub issue: https://github.com/agrinman/tunnelto/issues/51

Hi,

I'm having an issue with:

tunnelto 0.1.18

I'm trying to tunnel a wss connection however I'm getting an error. The same connection works with ngrock. The following are the two commands and the error logs:

ngrok http -region eu -hostname=### 172.28.1.3:8080
tunnelto --host 172.28.1.3 --subdomain ###--port 8080 -v

Logs:

101             GET     /v1/graphql
 DEBUG tunnelto::local                   > read from local service: "<non utf8>"
 DEBUG tunnelto::introspect::console_log > no log line for response
 INFO  tunnelto                          > got end stream [StreamId([206, 121, 210, 111, 39, 161, 7, 18])]
 DEBUG tunnelto                          > Processed packet: "END STREAM"
 DEBUG tunnelto::local                   > read from local service: "<non utf8>"
 DEBUG tunnelto::introspect::console_log > no log line for response
 WARN  tunnelto::local                   > closing stream
 DEBUG tunnelto::local                   > read from local service: "<non utf8>"
 DEBUG tunnelto::introspect::console_log > no log line for response
 WARN  tunnelto::local                   > closing stream
 ERROR tunnelto::introspect              > failed to write to incoming websocket: ConnectionClosed
 INFO  tunnelto::local                   > done reading from client stream
 ERROR tunnelto::introspect              > failed to write to incoming websocket: ConnectionClosed
 INFO  tunnelto::local                   > done reading from client stream
 ERROR tunnelto::introspect              > failed to write to incoming websocket: ConnectionClosed
 INFO  tunnelto::local                   > done reading from client stream
 ERROR tunnelto::introspect              > failed to write to incoming websocket: ConnectionClosed
 INFO  tunnelto::local                   > done reading from client stream
 DEBUG tunnelto::local                   > read from local service: "<non utf8>"
 DEBUG tunnelto::introspect::console_log > no log line for response
 WARN  tunnelto::local                   > closing stream
 ERROR tunnelto::introspect              > failed to write to incoming websocket: ConnectionClosed
 INFO  tunnelto::local                   > done reading from client stream
 ERROR tunnelto::introspect              > failed to write to incoming websocket: ConnectionClosed
 INFO  tunnelto::local                   > done reading from client stream
 INFO  tunnelto                          > stream["stream_iB4XD1s61LE"] -> init
 DEBUG tunnelto                          > Processed packet: "INIT STREAM"
 INFO  tunnelto                          > stream["stream_iB4XD1s61LE"] -> new data: 991
 INFO  tunnelto::local                   > setting up local stream: stream_iB4XD1s61LE
 INFO  tunnelto                          > forwarded to local tcp (stream_iB4XD1s61LE)
 DEBUG tunnelto                          > Processed packet: "STREAM DATA"
 DEBUG tunnelto::local                   > wrote to local service: 991
 DEBUG tunnelto::local                   > read from local service: "HTTP/1.1 101 Switching Protocols\r\nconnection: upgrade\r\nupgrade: websocket\r\nsec-websocket-accept: SKh2fziQyGpvgv3E0GZTAMiTZnI=\r\ndate: Fri, 04 Jun 2021 14:23:41 GMT\r\n\r\n"
Originally created by @wnz99 on GitHub (Jun 4, 2021). Original GitHub issue: https://github.com/agrinman/tunnelto/issues/51 Hi, I'm having an issue with: ``` tunnelto 0.1.18 ``` I'm trying to tunnel a wss connection however I'm getting an error. The same connection works with ngrock. The following are the two commands and the error logs: ``` ngrok http -region eu -hostname=### 172.28.1.3:8080 tunnelto --host 172.28.1.3 --subdomain ###--port 8080 -v ``` Logs: ``` 101 GET /v1/graphql DEBUG tunnelto::local > read from local service: "<non utf8>" DEBUG tunnelto::introspect::console_log > no log line for response INFO tunnelto > got end stream [StreamId([206, 121, 210, 111, 39, 161, 7, 18])] DEBUG tunnelto > Processed packet: "END STREAM" DEBUG tunnelto::local > read from local service: "<non utf8>" DEBUG tunnelto::introspect::console_log > no log line for response WARN tunnelto::local > closing stream DEBUG tunnelto::local > read from local service: "<non utf8>" DEBUG tunnelto::introspect::console_log > no log line for response WARN tunnelto::local > closing stream ERROR tunnelto::introspect > failed to write to incoming websocket: ConnectionClosed INFO tunnelto::local > done reading from client stream ERROR tunnelto::introspect > failed to write to incoming websocket: ConnectionClosed INFO tunnelto::local > done reading from client stream ERROR tunnelto::introspect > failed to write to incoming websocket: ConnectionClosed INFO tunnelto::local > done reading from client stream ERROR tunnelto::introspect > failed to write to incoming websocket: ConnectionClosed INFO tunnelto::local > done reading from client stream DEBUG tunnelto::local > read from local service: "<non utf8>" DEBUG tunnelto::introspect::console_log > no log line for response WARN tunnelto::local > closing stream ERROR tunnelto::introspect > failed to write to incoming websocket: ConnectionClosed INFO tunnelto::local > done reading from client stream ERROR tunnelto::introspect > failed to write to incoming websocket: ConnectionClosed INFO tunnelto::local > done reading from client stream INFO tunnelto > stream["stream_iB4XD1s61LE"] -> init DEBUG tunnelto > Processed packet: "INIT STREAM" INFO tunnelto > stream["stream_iB4XD1s61LE"] -> new data: 991 INFO tunnelto::local > setting up local stream: stream_iB4XD1s61LE INFO tunnelto > forwarded to local tcp (stream_iB4XD1s61LE) DEBUG tunnelto > Processed packet: "STREAM DATA" DEBUG tunnelto::local > wrote to local service: 991 DEBUG tunnelto::local > read from local service: "HTTP/1.1 101 Switching Protocols\r\nconnection: upgrade\r\nupgrade: websocket\r\nsec-websocket-accept: SKh2fziQyGpvgv3E0GZTAMiTZnI=\r\ndate: Fri, 04 Jun 2021 14:23:41 GMT\r\n\r\n" ```
Author
Owner

@FrancoAA commented on GitHub (Jun 9, 2021):

I'm having the same issues with websocket connections when trying to run a code-server instance. The issue doesn't happen when issue ngrock or localtunnel alternatives.

<!-- gh-comment-id:857887063 --> @FrancoAA commented on GitHub (Jun 9, 2021): I'm having the same issues with websocket connections when trying to run a code-server instance. The issue doesn't happen when issue ngrock or localtunnel alternatives.
Author
Owner

@samuelstroschein commented on GitHub (Jun 23, 2021):

Similar/same issue. I guess we are all using Hasura/GraphQL subscriptions over websockets? For unknown reasons, a websocket connection can not be established.

<!-- gh-comment-id:866828114 --> @samuelstroschein commented on GitHub (Jun 23, 2021): Similar/same issue. I guess we are all using Hasura/GraphQL subscriptions over websockets? For unknown reasons, a websocket connection can not be established.
Author
Owner

@wnz99 commented on GitHub (Jul 2, 2021):

Yes, it's Hasura subscriptions.

<!-- gh-comment-id:873171354 --> @wnz99 commented on GitHub (Jul 2, 2021): Yes, it's Hasura subscriptions.
Author
Owner

@mkjpryor commented on GitHub (Jul 6, 2021):

I'm also seeing similar issues when trying to expose a Guacamole console (https://guacamole.apache.org/). This works using localtunnel, but I preferred this implementation as (a) it is in Rust and (b) it has the potential to scale out.

I assume tunnelto is meant to support websockets?

<!-- gh-comment-id:874875548 --> @mkjpryor commented on GitHub (Jul 6, 2021): I'm also seeing similar issues when trying to expose a Guacamole console (https://guacamole.apache.org/). This works using `localtunnel`, but I preferred this implementation as (a) it is in Rust and (b) it has the potential to scale out. I assume `tunnelto` is meant to support websockets?
Author
Owner

@agrinman commented on GitHub (Jul 10, 2021):

Hi -- we do support web sockets, though it seems like something is not working with hasura/guacamole. For example, this web socket example works just fine from my testing: https://github.com/gorilla/websocket/tree/master/examples/chat (note: adjust ws to wss in the html).

Can someone share a simple to replicate example?

<!-- gh-comment-id:877636478 --> @agrinman commented on GitHub (Jul 10, 2021): Hi -- we do support web sockets, though it seems like something is not working with hasura/guacamole. For example, this web socket example works just fine from my testing: https://github.com/gorilla/websocket/tree/master/examples/chat (note: adjust `ws` to `wss` in the html). Can someone share a simple to replicate example?
Author
Owner

@agrinman commented on GitHub (Jul 19, 2021):

Hi: I rewrote a bit of the local tcp forwarding logic which I think might solve some of these more complex cases.
Would someone be able to try a latest version to see if this fixes it for them?

cargo install tunnelto --force --version 0.1.19

(note 0.1.19 is not pushed to brew just yet)
Thanks!

edit: it's really easy to get cargo if you don't have it, https://rustup.rs

<!-- gh-comment-id:882199533 --> @agrinman commented on GitHub (Jul 19, 2021): Hi: I rewrote a bit of the local tcp forwarding logic which I think might solve some of these more complex cases. Would someone be able to try a latest version to see if this fixes it for them? ``` cargo install tunnelto --force --version 0.1.19 ``` (note 0.1.19 is not pushed to brew just yet) Thanks! edit: it's really easy to get cargo if you don't have it, https://rustup.rs
Author
Owner

@jcroucher commented on GitHub (May 9, 2022):

0.1.19 fixed my issue loading wss urls

<!-- gh-comment-id:1120625955 --> @jcroucher commented on GitHub (May 9, 2022): 0.1.19 fixed my issue loading wss urls
Author
Owner

@jvalteren commented on GitHub (Jun 5, 2023):

Hi @agrinman, I too have issues with use of WebSockets and would like to try this 0.1.19 version. I'm using Homebrew on macOS. However, I can't find version 0.1.19 anywhere on GitHub or in Homebrew. Any pointers as to how I can get this version or fix the issue in another way?

<!-- gh-comment-id:1576458683 --> @jvalteren commented on GitHub (Jun 5, 2023): Hi @agrinman, I too have issues with use of WebSockets and would like to try this 0.1.19 version. I'm using Homebrew on macOS. However, I can't find version 0.1.19 anywhere on GitHub or in Homebrew. Any pointers as to how I can get this version or fix the issue in another way?
Author
Owner

@CWSpear commented on GitHub (Jun 26, 2023):

@jvalteren was having this issue and found this page as a result.

I'm on a Mac and was also using the Homebrew version.

cargo install tunnelto --force --version 0.1.19

(I have rust installed via Homebrew)

You do need to either uninstall the Homebrew version or make sure you're using the full path to the v0.1.19 one, e.g.:

/Users/cwspear/.cargo/bin/tunnelto --port 8080

All that said, I get a different error when using 0.1.19:

CONNECTION REFUSED
 ERROR tunnelto        > failed to open local tunnel
 ERROR tunnelto        > got data but no stream to send it to.
 ERROR tunnelto::local > failed to connect to local service: Connection refused (os error 61)

It doesn't work at all, so it's worse off than 0.1.18 :(

<!-- gh-comment-id:1607956206 --> @CWSpear commented on GitHub (Jun 26, 2023): @jvalteren was having this issue and found this page as a result. I'm on a Mac and was also using the Homebrew version. ``` cargo install tunnelto --force --version 0.1.19 ``` (I have `rust` installed via Homebrew) You do need to either uninstall the Homebrew version or make sure you're using the full path to the v0.1.19 one, e.g.: ``` /Users/cwspear/.cargo/bin/tunnelto --port 8080 ``` All that said, I get a _different_ error when using 0.1.19: ``` CONNECTION REFUSED ERROR tunnelto > failed to open local tunnel ERROR tunnelto > got data but no stream to send it to. ERROR tunnelto::local > failed to connect to local service: Connection refused (os error 61) ``` It doesn't work at all, so it's worse off than 0.1.18 :(
Author
Owner

@jvalteren commented on GitHub (Jun 27, 2023):

Thanks @CWSpear.

@agrinman what is the status of the rewritten local TCP forwarding logic? Any chance of pushing this to Homebrew?

<!-- gh-comment-id:1608845340 --> @jvalteren commented on GitHub (Jun 27, 2023): Thanks @CWSpear. @agrinman what is the status of the rewritten local TCP forwarding logic? Any chance of pushing this to Homebrew?
Author
Owner

@SerJaimeLannister commented on GitHub (Feb 14, 2025):

I tried this on a nat which doesn't have access to sudo / is a locked down , and I also face this same issue

ERROR tunnelto::local > failed to connect to local service: Connection refused (os error 111)
CONNECTION REFUSED
ERROR tunnelto > failed to open local tunnel
ERROR tunnelto > got data but no stream to send it to.
ERROR tunnelto::local > failed to connect to local service: Connection refused (os error 111)
CONNECTION REFUSED
ERROR tunnelto > failed to open local tunnel
ERROR tunnelto > got data but no stream to send it to.
ERROR tunnelto::local > failed to connect to local service: Connection refused (os error 111)
CONNECTION REFUSED
ERROR tunnelto > failed to open local tunnel
ERROR tunnelto > got data but no stream to send it to.
ERROR tunnelto::local > failed to connect to local service: Connection refused (os error 111)
CONNECTION REFUSED
ERROR tunnelto > failed to open local tunnel
ERROR tunnelto > got data but no stream to send it to.

<!-- gh-comment-id:2659828329 --> @SerJaimeLannister commented on GitHub (Feb 14, 2025): I tried this on a nat which doesn't have access to sudo / is a locked down , and I also face this same issue ERROR tunnelto::local > failed to connect to local service: Connection refused (os error 111) CONNECTION REFUSED ERROR tunnelto > failed to open local tunnel ERROR tunnelto > got data but no stream to send it to. ERROR tunnelto::local > failed to connect to local service: Connection refused (os error 111) CONNECTION REFUSED ERROR tunnelto > failed to open local tunnel ERROR tunnelto > got data but no stream to send it to. ERROR tunnelto::local > failed to connect to local service: Connection refused (os error 111) CONNECTION REFUSED ERROR tunnelto > failed to open local tunnel ERROR tunnelto > got data but no stream to send it to. ERROR tunnelto::local > failed to connect to local service: Connection refused (os error 111) CONNECTION REFUSED ERROR tunnelto > failed to open local tunnel ERROR tunnelto > got data but no stream to send it to.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tunnelto#43
No description provided.