socket.io icon indicating copy to clipboard operation
socket.io copied to clipboard

{ [Error: xhr post error] type: 'TransportError', description: 503 }

Open lonso opened this issue 11 years ago • 14 comments

socket.io client connect server client throw this error

{ [Error: xhr post error] type: 'TransportError', description: 503 }

more error info

  socket.io-client:manager will wait 1167ms before reconnect attempt +0ms
  engine.io-client:socket probe transport "websocket" failed because of error: socket closed +1ms
  engine.io-client:socket socket error {"description":503} +0ms
  socket.io-client:manager error +1ms { [Error: xhr poll error] description: 503 }

other question why i use socket.io-client connect server ,the transport is polling not websocket?

lonso avatar Feb 11 '15 05:02 lonso

What versions of server and client do you use? You basically need to use a same version.

why i use socket.io-client connect server, the transport is polling not websocket?

This is because socket.io uses polling first and attempts to upgrade transport to websocket by the default setting.

nkzawa avatar Feb 11 '15 20:02 nkzawa

i used socket.io and socket.io-client v.1.3.3

lonso avatar Feb 12 '15 03:02 lonso

Umm, I believe this is not the problem of socket.io since it sounds a very basic error and is well tested. Could you check your code again? Please post your code here If you couldn't resolve this.

nkzawa avatar Feb 12 '15 04:02 nkzawa

i used socket.io-client to stress test. server code:

//app is express V.3.x
var server = exports.server = require('http').createServer(app);
var io = exports.io = require('socket.io')(server, {
    allowUpgrades: true,
    transports: ['websocket', 'flashsocket', 'polling'],
    'log level': 1,
    'pingTimeout': 1000 * 80, 
    'pingInterval': 1000 * 25
});
var RedisStore = require('socket.io-redis');
var pub = redis.createClient(config.redis.port, config.redis.ip);
var sub = redis.createClient(config.redis.port, config.redis.ip, {detect_buffers: true});
io.adapter(RedisStore({pubClient: pub, subClient: sub}));

client code:

io.connect(config.serverAdd + '/wsservices', {
            'forceNew': true,
            'sync disconnect on unload': true,
            reconnect: false,
            query: {
                bestvid: "___" + bestId + "___",
                client_id: clientId,
                client_name: bestId,
                token: token,
                platform: platform
            }
        });

lonso avatar Feb 12 '15 04:02 lonso

So it seems your app was upgraded from 0.9.x to 1.3.3. I think you have to fix some options for the latest version, since there are a ton of changes between these versions. Especially, I wonder the transports would work with the setting (['websocket', 'flashsocket', 'polling']).

nkzawa avatar Feb 12 '15 05:02 nkzawa

client or server?

lonso avatar Feb 12 '15 05:02 lonso

Both have to be fixed. Please see the doc for the details.

http://socket.io/docs/migrating-from-0-9

nkzawa avatar Feb 12 '15 05:02 nkzawa

i write a testcase to stress test. i run 1000 client to connect server once. when i run three time's the connect will be slowly and many reconnect event.

[root@localhost]# ulimit 
unlimited

i don't know why, in the v0.9 not existed this question.

some debug info

Thu, 12 Feb 2015 07:05:04 GMT engine.io-client:socket socket closing - telling transport to close
Thu, 12 Feb 2015 07:05:04 GMT engine.io-client:socket socket close with reason: "forced close"

lonso avatar Feb 12 '15 06:02 lonso

fixed,this error need to set client transports like this.

io.connect(config.serverAdd + '/wsservices', {
            ...
            transports: ['websocket''],
            ....
        });

lonso avatar Feb 12 '15 07:02 lonso

When I set transports to ['websocket'], I got an error 'connect_error', [Error: websocket error]. But, when I change to { transports: ['websocket'] }, I also got an error 'connect_error', [Error: xhr poll error]

minhquankq avatar Apr 03 '17 08:04 minhquankq

+1

waseemshahwan avatar Jun 14 '17 23:06 waseemshahwan

+1

dmitriy-kazarinov avatar Nov 24 '17 09:11 dmitriy-kazarinov

@minhquankq how did you solve it?

kuriel-dev avatar Feb 24 '19 18:02 kuriel-dev

+1 here (after many connection depending on the hardware machine)

alfonsograziano avatar Mar 17 '21 21:03 alfonsograziano