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

Websockets behind http2 nginx #15028

Closed
magnetic5355 opened this issue Jul 21, 2019 · 3 comments
Closed

Websockets behind http2 nginx #15028

magnetic5355 opened this issue Jul 21, 2019 · 3 comments
Labels
stat: stale Stale issues will be automatically closed if no activity

Comments

@magnetic5355
Copy link

Description:

Client connection issues on Android / ios and destkop. I believe the cause is HTTP2 reverse proxy.

Clients work however they frequently show "disconnected" "reconnecting" etc.

I ran the same tests on the open.rocket.chat and received the same response as our domain.

Steps to reproduce:

  1. curl -i -N -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Host: open.rocket.chat" -H "Origin: open.rocket.chat" -H "Sec-WebSocket-Key: JKQgGgL0BZ5uBnFnEFvsKQ==" -H "Sec-WebSocket-Version: 13" https://open.rocket.chat/websocket

(use a curl client with HTTP2)

Results in * Connection state changed (MAX_CONCURRENT_STREAMS == 250)!
< HTTP/2 400
HTTP/2 400
< date: Sun, 21 Jul 2019 16:38:19 GMT
date: Sun, 21 Jul 2019 16:38:19 GMT
< set-cookie: _f993b=http://10.10.50.242:3000; Path=/
set-cookie: _f993b=http://10.10.50.242:3000; Path=/
< content-type: text/plain; charset=utf-8
content-type: text/plain; charset=utf-8
< content-length: 29
content-length: 29

<
Not a valid websocket request* Connection #0 to host open.rocket.chat left intact

Then attempt with 1.1

curl -i -N -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Host: open.rocket.chat" -H "Origin: open.rocket.chat" -H "Sec-WebSocket-Key: JKQgGgL0BZ5uBnFnEFvsKQ==" -H "Sec-WebSocket-Version: 13" https://open.rocket.chat/websocket -v --http1.1

  • Mark bundle as not supporting multiuse
    < HTTP/1.1 101 Switching Protocols
    HTTP/1.1 101 Switching Protocols
    < Upgrade: websocket
    Upgrade: websocket
    < Connection: Upgrade
    Connection: Upgrade
    < Sec-WebSocket-Accept: PVT/B550DR00T9L0+tGlhVQPSbY=
    Sec-WebSocket-Accept: PVT/B550DR00T9L0+tGlhVQPSbY=
    < Set-Cookie: _f993b=http://10.10.17.50:3000; Path=/
    Set-Cookie: _f993b=http://10.10.17.50:3000; Path=/

<
��{"server_id":"0"}

Expected behavior:

Valid websocket setup when behind http2 reverse proxy

Actual behavior:

Web-sockets fail to establish - chrome stops on switching protocol

image

Server Setup Information:

  • Version of Rocket.Chat Server: 1.1.3
  • Operating System: Ubuntu 18.04
  • Deployment Method: SNAP
  • Number of Running Instances:
  • DB Replicaset Oplog:
  • NodeJS Version:
  • MongoDB Version:

Additional context

Clients frequently display "disconnected" and "reconnecting" - I'm hoping this is why and there is a solution.

Followed setup from https://github.com/RocketChat/Rocket.Chat.RaspberryPi/wiki/NGINX-reverse-proxy-for-Rocket.Chat-Snap-installation

Relevant logs:

@reetp
Copy link

reetp commented Jul 22, 2019

Yes there is a disparity between these:

https://github.com/RocketChat/Rocket.Chat.RaspberryPi/wiki/NGINX-reverse-proxy-for-Rocket.Chat-Snap-installation

https://rocket.chat/docs/installation/manual-installation/configuring-ssl-reverse-proxy/#running-behind-a-nginx-ssl-reverse-proxy

The only config seeming to show http2 is the Raspberry Pi version.

Nonetheless I upgraded my test docker rig to http2 and it works without issues.

-    listen 1.2.3.4:443;
+    listen 1.2.3.4:443 ssl http2;

nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

service nginx restart

Try reconnecting with Rocket:

Screenshot_2019-07-22_14-44-05

Screenshot_2019-07-22_14-50-31

So this most likely is not your issue.

@github-actions
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@homberger
Copy link

homberger commented Apr 6, 2022

Yes there is a disparity between these:

https://github.com/RocketChat/Rocket.Chat.RaspberryPi/wiki/NGINX-reverse-proxy-for-Rocket.Chat-Snap-installation

https://rocket.chat/docs/installation/manual-installation/configuring-ssl-reverse-proxy/#running-behind-a-nginx-ssl-reverse-proxy

The only config seeming to show http2 is the Raspberry Pi version.

Be aware: There is was an error in the linked nginx configuration example of the Raspberry Pi version. It is using X-Forward-* instead of X-Forwarded-*.

This error persists since a long time: RocketChat/developer-docs@a1ebcd1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stat: stale Stale issues will be automatically closed if no activity
Projects
None yet
Development

No branches or pull requests

3 participants