Welcome! Log In Create A New Profile

Advanced

Re: Websocket handshake failing

Maxim Dounin
July 30, 2015 01:46PM
Hello!

On Thu, Jul 30, 2015 at 11:19:32AM -0400, nightcrawler wrote:

> I'm trying to enable websocket communication between client and server and
> have nginx as proxy. Ive applied the following congiguration changes to
> websocket sites-enabled conf to allow for websocket proxy:
> proxy_set_header Upgrade $http_upgrade;
> proxy_set_header Connection "upgrade";
> proxy_set_header X-Forwarded-For $http_x_forwarded_for;
> proxy_set_header Host $http_host;
> proxy_pass http://mywebsite;
>
> Although the server receives the Connection: Upgrade header and responds
> with aConnection: Upgrade header as expected, the client gets only
> Connection: keep-alive and I see the following error on js-console
>
> WebSocket connection to 'wss://mywebsite.dev/cometd/' failed: Error during
> WebSocket handshake: 'Connection' header value must contain 'Upgrade'
>
> I feel that nginx might not be proxying the response correctly either due to
> incorrect response or bad config.
>
> Can someone help me out with debugging this? A lot of places where I see
> this issue, usually the proxy does not support the websocket handshake which
> causes the handshake to fail.

Connections upgrades are supported by nginx proxy starting with
nginx 1.3.13. Make sure you are using recent enough version, not
something from Debian oldstable.

You also need to configure nginx properly. Detailed documentation
can be found here:

http://nginx.org/en/docs/http/websocket.html

In the config snippet you've provided at least "proxy_http_version 1.1;"
seems to be missing.

If the above won't help, consider looking at nginx debugging logs.
See here for some basic hints:

http://nginx.org/en/docs/debugging_log.html

--
Maxim Dounin
http://nginx.org/

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Websocket handshake failing

nightcrawler July 30, 2015 11:19AM

Re: Websocket handshake failing

Maxim Dounin July 30, 2015 01:46PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 181
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready