0

I have a really strange issue going on here in a socket.io development.

Everything is working just fine (emits to/from server) except that from a 3G connection the server does the following:

console.log( io.sockets.adapter.rooms['thisroom'] )

This line, almost every time, returns a typeof of 'undefined', as if there where not sockets connected in the given 'thisroom' room when there actually are sockets connected to the room.

If the same code is executed from a WIFI connection, under the same circumstances, with the same sockets connected, the above line returns something like:

Room { sockets: { '/#wEkHFuAhbCEf1Dw2AAAC': true }, length: 1 }

which is correct.

I've tried everything with this as to:

Tried socket.io version 1.3.7

Tried socket.io version 1.4.8

Tried to connect with

var socket = io.connect("http://<ip>:8081");

Tried to force to websockets transport only with:

var socket = io.connect("http://<ip>:8081", {transports: ['websocket']});

Tried to use two transports as:

var socket = io.connect("http://<ip>:8081", {transports: ['websocket', 'polling']});

Nothing worked.

It is really weird because sometimes, the 3G connection works as expected when just restarting the app. But most of the time, it does work.

Ideas?

Luciano
  • 103
  • 1
  • 2
  • 9
  • 1
    Sometimes, 3G throws websocket implementations off the tracks, by trying to "correct" the "http" requests... did you try using TLS to prevent third party data injection (even well intended, it still causes issues)? – Myst Jul 06 '16 at 23:53
  • Are you sure that the 3G network has access to your IP address and port? Remember that the 3G network connection will be coming from outside your firewall, but the WiFi network connection will be coming from inside your firewall/router. – jfriend00 Jul 07 '16 at 03:00
  • Have you done any client-side debugging to see if the client thinks it is connected? And, what about server logging of incoming connections and room creations? What do you see on both client and server from the 3G network? – jfriend00 Jul 07 '16 at 03:01
  • @jfriend00 yes, 3G has acccess to the IP and port. As a matter of fact, a socket.io connection is successfull, emits works just ok. The only problem is when trying to get sockets from a room. – Luciano Jul 07 '16 at 13:44

1 Answers1

0

I just managed to make it work by using a secured connection with SSL. Under SSL, io.sockets.adapter.rooms['thisroom'] works every time in any 3G connection.

Luciano
  • 103
  • 1
  • 2
  • 9