Skip to content
This repository has been archived by the owner on Jul 7, 2022. It is now read-only.

Getting websocket error code 1006 in iOS. #25

Closed
viniciodeltoro opened this issue Apr 6, 2017 · 7 comments
Closed

Getting websocket error code 1006 in iOS. #25

viniciodeltoro opened this issue Apr 6, 2017 · 7 comments

Comments

@viniciodeltoro
Copy link

I'm using an Actioncable js file to connect to an Actioncable rails server. This actioncable js file uses this nativescript-websockets plugin.
I have been doing connection testing on Android and it works properly, the connection works properly on the web browser as well but when I run it on iOS I get an error like this:
Socket was closed because: code: 1006
This link explains that the connection gets closed abnormally because some incompatibility between the server and the client. I don't really know can can be the issue.
I did post in Stackoverflow since I thought the issue was happening because of the protocols used (actioncable-v1-json, actioncable-unsupported), but even if I don't provide these protocols on the browser test, the connection still works.

Any ideas on what is causing this issue?
Thanks

@NathanaelA
Copy link
Owner

Does your server by any chance have compression on. Someone reported compression was broken on iOS a while ago; and I haven't had a chance to verify or do anything about it if it is... Disabling compression would fix the issue.

@dapperapps
Copy link

+1 having same issue

@zahid-dapperapps
Copy link

@viniciodeltoro Please share server code. Have you compared between request that is recevied from iOS and request that is recevied from android builds

@viniciodeltoro
Copy link
Author

Sorry I don't have the code anymore I ended up switching to socket.io and using a Node server dedicated for websocket communications only.

@zahid-dapperapps
Copy link

zahid-dapperapps commented May 14, 2017

I have provided 2 possible solutions here http://stackoverflow.com/a/43952323/319297

My setup is Rails 5 and

    "tns-ios": {
      "version": "2.5.0"
    }

This solution had worked for me.

@soulfly
Copy link
Contributor

soulfly commented Dec 15, 2017

Had the same issues recently,

In my case it was a problem in WebSocket rfc6455 - different implementation on client and server
and the issue was in dependant iOS lib - PocketSocket

More details here
zwopple/PocketSocket#73

So I simply added

this._headers['Connection'] = "Upgrade";
after
this._headers = options.headers || [];

in websockets.ios.js file

@NathanaelA
Copy link
Owner

This fix Igor provided has been present in v1.4 or later. If anyone has any more issues with iOS please open a new issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants