Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use with cloudflared tunnel: stream error: stream ID 3; PROTOCOL_ERROR #21

Open
bbigras opened this issue Jul 10, 2021 · 0 comments

Comments

@bbigras
Copy link

bbigras commented Jul 10, 2021

The websocket connection works when I'm testing on my machine with localhost but for some reason, when I'm using it deployed with cloudflared the websocket opens but closes immediately with an 1006 error code.

If I test with the "simple websocket client" Chrome extension, I get the same problem. But if I try a simple nodejs websocket server, it works, so I'm guessing maybe the problem is with tide-websockets.

Also, it seems that my backend is sending data to the websocket, but I don't get it on the browser side.

Don't hesitate if you want me to test anything or provide a cloudflared config file example.

tide-websockets: 0.4.0
tungstenite: 0.13
async-tungstenite: 0.13.1

cloudflared log

2021-07-10T08:43:40Z DBG CF-RAY: 66c8817b4ad719f3-EWR GET /as_endpoint HTTP/2.0
2021-07-10T08:43:40Z DBG Inbound request CF-RAY=66c8817b4ad719f3-EWR Header="map[Accept-Encoding:[gzip] Accept-Language:[fr-CA,fr;q=0.9,en-CA;q=0.8,en;q=0.7,fr-FR;q=0.6,en-US;q=0.5] Cache-Control:[no-cache] Cdn-Loop:[cloudflare] Cf-Connecting-Ip:[142.119.3.135] Cf-Ipcountry:[CA] Cf-Ray:[66c8817b4ad719f3-EWR] Cf-Visitor:[{\"scheme\":\"https\"}] Cf-Warp-Tag-Id:[34d63501-58fa-42e7-80b2-f0d2d9d6641a] Origin:[chrome-extension://pfdhoblngboilpfeibdedpjgfnlcodoo] Pragma:[no-cache] Sec-Websocket-Extensions:[permessage-deflate; client_max_window_bits] Sec-Websocket-Key:[v3qtg+YnhA9QmPForWelsA==] Sec-Websocket-Version:[13] User-Agent:[Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36] X-Forwarded-For:[142.119.3.135] X-Forwarded-Proto:[https]]" host=my_hostname path=/as_endpoint rule=0
2021-07-10T08:43:40Z DBG CF-RAY: 66c8817b4ad719f3-EWR Request Content length unknown
2021-07-10T08:43:40Z DBG origin to tunnel copy: read tcp 127.0.0.1:42228->127.0.0.1:8378: use of closed network connection
2021-07-10T08:43:40Z DBG CF-RAY: 66c8817b4ad719f3-EWR Status: 101 Switching Protocols served by ingress 0
2021-07-10T08:43:40Z DBG CF-RAY: 66c8817b4ad719f3-EWR Response Headers map[Connection:[Upgrade] Content-Length:[0] Date:[Sat, 10 Jul 2021 08:43:40 GMT] Sec-Websocket-Accept:[WeH80atTrSGYEFBFOPqvTmC+J8I=] Sec-Websocket-Version:[13] Upgrade:[websocket]]
2021-07-10T08:43:40Z DBG CF-RAY: 66c8817b4ad719f3-EWR Response content length 0
2021-07-10T08:43:40Z DBG tunnel to origin copy: stream error: stream ID 3; PROTOCOL_ERROR

tcpdump

✦ ❯ sudo tcpdump -A -i any port 8378
tcpdump: data link type LINUX_SLL2
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on any, link-type LINUX_SLL2 (Linux cooked v2), snapshot length 262144 bytes
08:43:40.797218 lo    In  IP localhost.42228 > localhost.cruise-config: Flags [S], seq 552307204, win 65495, options [mss 65495,sackOK,TS val 756630405 ecr 0,nop,wscale 7], length 0
E..</3@.@............. . ............0.........
-.C.........
08:43:40.797242 lo    In  IP localhost.cruise-config > localhost.42228: Flags [S.], seq 4166726621, ack 552307205, win 65483, options [mss 65495,sackOK,TS val 756630405 ecr 756630405,nop,wscale 7], length 0
E..<..@.@.<......... ....[3. ........0.........
-.C.-.C.....
08:43:40.797255 lo    In  IP localhost.42228 > localhost.cruise-config: Flags [.], ack 1, win 512, options [nop,nop,TS val 756630405 ecr 756630405], length 0
E..4/4@.@............. . ....[3......(.....
-.C.-.C.
08:43:40.817118 lo    In  IP localhost.42228 > localhost.cruise-config: Flags [P.], seq 1:816, ack 1, win 512, options [nop,nop,TS val 756630425 ecr 756630405], length 815
E..c/5@.@.
^.......... . ....[3......X.....
-.C.-.C.GET /as_endpoint HTTP/1.1
Host: my_hostname
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36
Accept-Encoding: gzip
Accept-Language: fr-CA,fr;q=0.9,en-CA;q=0.8,en;q=0.7,fr-FR;q=0.6,en-US;q=0.5
Cache-Control: no-cache
Cdn-Loop: cloudflare
Cf-Connecting-Ip: my_ip
Cf-Ipcountry: CA
Cf-Ray: 66c8817b4ad719f3-EWR
Cf-Visitor: {"scheme":"https"}
Cf-Warp-Tag-Id: 34d63501-58fa-42e7-80b2-f0d2d9d6641a
Connection: Upgrade
Origin: chrome-extension://pfdhoblngboilpfeibdedpjgfnlcodoo
Pragma: no-cache
Sec-Websocket-Extensions: permessage-deflate; client_max_window_bits
Sec-Websocket-Key: v3qtg+YnhA9QmPForWelsA==
Sec-Websocket-Version: 13
Upgrade: websocket
X-Forwarded-For: my_ip
X-Forwarded-Proto: https


08:43:40.817134 lo    In  IP localhost.cruise-config > localhost.42228: Flags [.], ack 816, win 506, options [nop,nop,TS val 756630425 ecr 756630425], length 0
E..4.q@.@.'Q........ ....[3. ..4.....(.....
-.C.-.C.
08:43:40.840487 lo    In  IP localhost.cruise-config > localhost.42228: Flags [P.], seq 1:213, ack 816, win 512, options [nop,nop,TS val 756630448 ecr 756630425], length 212
E....r@.@.&|........ ....[3. ..4...........
-.C.-.C.HTTP/1.1 101 Switching Protocols
connection: Upgrade
content-length: 0
date: Sat, 10 Jul 2021 08:43:40 GMT
sec-websocket-accept: WeH80atTrSGYEFBFOPqvTmC+J8I=
sec-websocket-version: 13
upgrade: websocket


08:43:40.840520 lo    In  IP localhost.42228 > localhost.cruise-config: Flags [.], ack 213, win 511, options [nop,nop,TS val 756630448 ecr 756630448], length 0
E..4/6@.@............. . ..4.[4......(.....
-.C.-.C.
08:43:40.885283 lo    In  IP localhost.cruise-config > localhost.42228: Flags [P.], seq 213:229, ack 816, win 512, options [nop,nop,TS val 756630493 ecr 756630448], length 16
E..D.s@.@.'?........ ....[4. ..4.....8.....
-.C.-.C...{"Servers":[]}
08:43:40.885336 lo    In  IP localhost.42228 > localhost.cruise-config: Flags [.], ack 229, win 511, options [nop,nop,TS val 756630493 ecr 756630493], length 0
E..4/7@.@............. . ..4.[4......(.....
-.C.-.C.
08:43:40.886539 lo    In  IP localhost.cruise-config > localhost.42228: Flags [P.], seq 229:251, ack 816, win 512, options [nop,nop,TS val 756630494 ecr 756630493], length 22
E..J.t@.@.'8........ ....[4. ..4.....>.....
-.C.-.C...{"NbPlayersInit":[]}
08:43:40.886551 lo    In  IP localhost.42228 > localhost.cruise-config: Flags [.], ack 251, win 511, options [nop,nop,TS val 756630494 ecr 756630494], length 0
E..4/8@.@............. . ..4.[4......(.....
-.C.-.C.
08:43:40.889282 lo    In  IP localhost.42228 > localhost.cruise-config: Flags [F.], seq 816, ack 251, win 512, options [nop,nop,TS val 756630497 ecr 756630494], length 0
E..4/9@.@............. . ..4.[4......(.....
-.C.-.C.
08:43:40.930087 lo    In  IP localhost.cruise-config > localhost.42228: Flags [.], ack 817, win 512, options [nop,nop,TS val 756630538 ecr 756630497], length 0
E..4.u@.@.'M........ ....[4. ..5.....(.....
-.D
-.C.

^C
13 packets captured
61 packets received by filter
0 packets dropped by kernel

my backend log

jui 10 08:43:40 vps tide-ws-back-start[1448913]: {"level":30,"time":1625906620840,"msg":"--> Response sent","method":GET,"path":/as_endpoint,"status":101 - Switching Protocols,"duration":4.836325ms}
jui 10 08:43:40 vps tide-ws-back-start[1448913]: new ws
[...]
jui 10 08:43:40 vps tide-ws-back-start[1448913]: {"level":30,"time":1625906620882,"msg":"send ws: Servers([])"}
jui 10 08:43:40 vps tide-ws-back-start[1448913]: {"level":30,"time":1625906620885,"msg":"send ws: NbPlayersInit([])"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant