Closed pristavu closed 8 years ago
Hi @pristavu
check your nginx error log, probably the Safari you are using uses a WebSocket version not supported on this module.
2014/02/23 22:21:47 [debug] 19191#0: *1973 HTTP/1.1 400 Bad Request Server: nginx Date: Sun, 23 Feb 2014 20:21:47 GMT Content-Length: 0 Connection: close Expires: Thu, 01 Jan 1970 00:00:01 GMT Cache-Control: no-cache, no-store, must-revalidate X-Nginx-PushStream-Explain: Don't have at least one of the mandatory headers: Connection, Upgrade, Sec-WebSocket-Key and Sec-WebSocket-Version
I`m testing on safari 5.1.7 Windows version
Check the version number that your browser is sending on Sec-WebSocket-Version header. The module only supports the 8 and 13 versions.
I'm testing on google chrome 34.0.1772.0 and I have the same error. Can you show some browsers whose Sec-WebSocket-Version header is 8 or 13. Thanks.
I'm using chrome 35.0.1916.153, and works fine. But chrome is supported since I implemented this feature on the module a long time ago.
Is this still an issue for anybody?
I ran into this the last days as well (while testing with safari 5.1.7 on win7) and fixed it by adding the following code to latest pushstream.js (@line ~545):
var WebSocketWrapper = function(pushstream) {
+ // With many thanks to: https://groups.google.com/forum/#!topic/nginxpushstream/GpXxpNF197A
+ var ua = navigator.userAgent.toLowerCase();
+ if (ua.indexOf("safari") != -1) {
+ var version_safari = ua.substr(ua.indexOf("version")+8,2);
+ version_safari = version_safari.split(".").join("")*1;
+ if (version_safari < 6) { throw "WebSocket not supported"; }
+ }
if (!window.WebSocket && !window.MozWebSocket) { throw "WebSocket not supported"; }
this.type = WebSocketWrapper.TYPE;
this.pushstream = pushstream;
this.connection = null;
};
Hope that will be accepted (and maybe integrated for backward compatibility as well?) by copyright holders ;-) Any idea for better implementation is appreciated.
Cheers Dan
@dquappe I would like to thank you for your suggestion but I will refuse it. I don't like very much to add code specific to one browser, at least until it became very necessary. Another reason is Safari support for windows was discontinued a long time ago, so does note make much sense add support for a dead browser, is quite the same to write code for IE 6 ;)
The PushStream javascript client is prepared to try another connection mode if the first try have failed. Of course, this take a little bit more time to fallback to long polling, as example. If this wait is a big issue for you, you can use this same snippet at your application in the time you instantiate a PushStream object to not set "websocket" as a "modes" option on that browser.
removing all channels adding channel 21 adding channel 22 adding channel 24 adding channel 25 adding channel 23 adding channel 26 adding channel notifications status changed 1 [WebSocket] connecting to: wss://localhost/ws/21/22/24/25/23/26/notifications?_=1393122447547&tag=&time=&eventid= Unexpected response code: 400 - https://localhost/
[WebSocket] error (disconnected by server): CloseEvent bubbles: false cancelBubble: false cancelable: false clipboardData: undefined constructor: CloseEventConstructor currentTarget: WebSocket defaultPrevented: false eventPhase: 2 returnValue: true srcElement: WebSocket target: WebSocket timeStamp: 1393122448203 type: "close" wasClean: false proto: CloseEventPrototype
status changed 0 trying to reconnect in 60000
status changed 1 [EventSource] connecting to: https://localhost/ev/21/22/24/25/23/26/notifications?_=1393122508205&tag=&time=&eventid= status changed 2 [EventSource] connection opened