SocketCluster / socketcluster-client

JavaScript client for SocketCluster

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Socketcluster client and nativescript not playing nice

jcjmcclean opened this issue · comments

I've got a nativescript project which needs to interface with a socketcluster server. I've already created a proof of concept in angular (without nativescript), which works perfectly using socketcluster browser client - but I can't get the nativescript angular android app to work with socketcluster (using the same browser client).

Nativescript doesn't support websockets out of the box, there's a plugin nativescript-websockets which enables websocket support. I created another proof of concept in nativescript using a vanilla websocket server and the nativescript-websockets plugin which worked perfectly again (connected, received and sent messages + disconnected).

So now I know that socketcluster.js browser client works with angular and nativescript-websockets works with nativescript. I need to combine the 2 to enable my nativescript app to connect to the socketcluster server...

I edited the socketcluster.js browser client to switch out line 1304 (WebSocket = _dereq_('ws');) for the nativescript websockets library WebSocket = require('nativescript-websockets'); hoping that would enable the socketcluster library to work with nativescript.

The response I'm getting from that is error code 4007: 'ERROR SocketProtocolError: Client connection establishment timed out'.

I can connect to the server with the same settings from the angular app and vanilla websockets works on nativescript, so something isn't playing nice between socketcluster client and nativescript-websockets.

WIRESHARK
I setup wireshark to listen for websocket packets, so I can see if/when the socketcluster connection is created. It works great with the angular app and with vanilla websockets on nativescript but sees nothing at all happening when I'm using socketcluster client in the nativescript app, it's like the websocket connection isn't even being attempted.

TL;DR
Trying to get socketcluster client working on a nativescript application using nativescript-websockets. Getting timeout errors. Same code works in angular app.

Question:
Is there any debugging available within socketcluster client?