WebSocket connection failed on mobile network on port 8080 or 80

In my web application, I use Node.js and Socket.io.

Since I am testing the application locally or on my Wi-Fi network, everything was fine, but since I switched to mobile data, I received a connection error:

WebSocket connection for 'WS: //url/socket.io/1/websocket/' failed: WebSocket handshake error: Unexpected response code: 502

It seems like my mobile provider is blocking ports 8080 and 80, but switching to another port seems impossible with nodejitsu.

Does anyone have experience with a mobile network, Node.js and socket.io?

EDIT:
As a host, I tried a free Heroku subscription and a Nodejitsu free subscription.

On a mobile device, I checked the ports at http://websocketstest.com/ with a mobile phone and Wi-Fi. On a mobile device, the test failed with ports 80 and 8080.
I thought maybe I can change the port to 443, but nodejitsu seems to be listening on port 80, even if I installed server.listen()on port 443.

I think that WebSockets may be possible, maybe through a different port, but I don’t know how to change the port or why nodejitsu, for example, just listens on port 80.

+4
source share
3 answers

HTTP 502 means "Bad Gateway" and usually a reverse proxy sign somewhere along the path between the client and server.

, - , websocket ( flashsocket) socket.io:

var io = require('socket.io').listen(...);

io.set('transports', [ 'xhr-polling', 'jsonp-polling', 'htmlfile' ]);
+3

:

var io= require('socket.io');
io.set("transports", ["xhr-polling"]);
+1

node.js - Wi-Fi. 502. , heroku/nodejitsu.

, . . Websockets -, http1.1 , http ws-. - HTTP-, (, @roberklep Opera Turbo) , - .

http 80 https 443 ( SSL, TLS) . , .

fooobar.com/questions/1514324/..., , https node.js :

var sslOptions = {
  key: fs.readFileSync(__dirname + '/../ssl/server.key,
  cert: fs.readFileSync(__dirname + '/../ssl/server.pem,
  ciphers: 'ECDHE-RSA-AES256-SHA:AES256-SHA:RC4-SHA:RC4:HIGH:!MD5:!aNULL:!EDH:!AESGCM',
  honorCipherOrder: true };

var server = https.createServer(sslOptions, app); server.listen(443);

SSL/TLS, , .

+1

All Articles