SocketCluster / socketcluster-client

JavaScript client for SocketCluster
MIT License
290 stars 92 forks source link

Socketcluster client and nativescript not playing nice #127

Closed jcjmcclean closed 4 years ago

jcjmcclean commented 5 years ago

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?

jcjmcclean commented 5 years ago

For reference links to other issues also opened: https://github.com/SocketCluster/socketcluster/issues/496 https://github.com/NathanaelA/nativescript-websockets/issues/67