Muhammad Umer
Muhammad Umer

Reputation: 18097

Websocket connection works in chrome but fails to connect in firefox?

Everything works as it should in chrome. no problems.

In Firefox i get an error : Firefox can't establish a connection to the server at wss://domain.com

This is reproducible if you go to https://websocket.org/echo.html and replace location with wss://domain.com in chrome it works and ff it doesn't.

I'm unable to figure out why?

Using Nodejs and running on heroku, behind cloudflare.

Edit

So I fixed from hint by Brad.

I am using https://github.com/websockets/ws/blob/master/doc/ws.md for websocket. it has an option perMessageDeflate.

Disabling it now make it work in FF.

Not sure What is happening but this fixed it. (am i suppose to this lib on client side as well?)

Only thing I found on MDN is this

Gecko 8.0 Starting in Gecko 8.0 (Firefox 8.0 / Thunderbird 8.0 / SeaMonkey 2.5), the deflate-stream extension to the WebSocket protocol has been disabled, since it's been deprecated from the specification drafts. This resolves incompatibilities with some sites.

Upvotes: 6

Views: 9607

Answers (1)

Brad
Brad

Reputation: 163272

You're getting a 400 Bad Request back for Firefox users. It isn't immediately apparent as to why. The request data between Firefox and Chrome is almost identical. The only difference I see is Chrome has more for this header:

Sec-Websocket-Extensions: permessage-deflate; client_max_window_bits=10; server_no_context_takeover; client_no_context_takeover; server_max_window_bits=10.

Upvotes: 6

Related Questions