joewalnes / reconnecting-websocket

A small decorator for the JavaScript WebSocket API that automatically reconnects
MIT License
4.21k stars 969 forks source link

Issue when using in cordova app running in old android phones #38

Open varghesethomase opened 9 years ago

varghesethomase commented 9 years ago

I tried using this plugin in cordova app. It works in new web views when running in new android phones( kitkat and above ) but found that it does't work in many old phones.

joewalnes commented 9 years ago

Please leave a more helpful bug report. What phones does it not work on? Which parts do not work? Are there any JavaScript errors?

agalazis commented 9 years ago

Websockets do not work on many old phones anw, have you tried plain web-sockets(without this library)?

agalazis commented 9 years ago

If plain web-sockets don't work use this:https://github.com/knowledgecode/WebSocket-for-Android (I suggest closing this issue as android versions less than kitkat do not support web-sockets unless they have a custom factory default browser that does so, other than that the above library solves the issue)

imgxx commented 9 years ago

I have the same issue. var ws = new WebSocket(WEBSOCKETURL); works for me on android 4.2

agalazis commented 9 years ago

what's the issue? if new WebSocket(WEBSOCKETURL)works, new ReconnectingWebSocket should work. Do you get any error? for me it worked fine the only trick i had to do was to close the socket manually before unload in order to avoid crashes(I was also using https://github.com/knowledgecode/WebSocket-for-Android)

felice commented 8 years ago

A bit late but i had the same issue and found out that on Ios 5.1.1 (hixie-76) the use of the second argument (protocols) triggers two errors: Wrong protocol for WebSocket '' and _SYNTAXERR: DOM Exception 12 May be related: https://bugs.webkit.org/show_bug.cgi?id=46942 In my case the solution was changing the line ws = new WebSocket(self.url, protocols || []); to if (protocols) { ws = new WebSocket(self.url, protocols); } else { ws = new WebSocket(self.url); } Works also in current versions of Firefox, Chrome and Safari also mobile versions. HTH