Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Socket.io bad request with response {"code":0,"message":"Transport unknown"}?

I'm trying to run socket.io and I'm getting a bunch of these:

http://domain.com:8080/socket.io/?EIO=2&transport=polling&t=1401421022966-0 400 (Bad Request) 

This is the response I'm getting:

{"code":0,"message":"Transport unknown"}

I can't find any reason. I read somewhere that it might be misinterpreting the client, but that's about as far as I could get.

like image 234
JVE999 Avatar asked May 30 '14 03:05

JVE999


People also ask

Why is Socket.IO not connecting?

Problem: the socket is not able to connect​You are trying to reach a plain WebSocket server. The server is not reachable. The client is not compatible with the version of the server. The server does not send the necessary CORS headers.

Does Socket.IO reconnect after disconnect?

This event is fired upon disconnection. In the first two cases (explicit disconnection), the client will not try to reconnect and you need to manually call socket. connect() .

Can Socket.IO connect to WebSocket server?

Although Socket.IO indeed uses WebSocket for transport when possible, it adds additional metadata to each packet. That is why a WebSocket client will not be able to successfully connect to a Socket.IO server, and a Socket.IO client will not be able to connect to a plain WebSocket server either.


2 Answers

I had the same issue after upgrading from 0.9.x to 1.x.x. Shortening the long story, I would set transports to ['websocket', 'polling'] and then the error...

when you config your server to use specefic transpors you should set the same config on client side to...

server

    var io = require('socket.io')(server, {'transports': ['websocket', 'polling']});

client

    var io = io( serverUri, {'transports': ['websocket', 'polling']});
like image 120
smbeiragh Avatar answered Sep 22 '22 04:09

smbeiragh


I had the same issue,after upgrading from 0.9.x, turns out my server config was set to ['websocket', 'jsonp-polling'] which was valid in 0.9 but the default config for the client and server is now ['polling', 'websocket']. Removing my server config got me up and running.

The config is now documented in engine.io (https://github.com/automattic/engine.io), the new transport layer introduced in 1.0 - in particular this line:
transports ( String): transports to allow connections to (['polling', 'websocket'])

like image 24
johnl Avatar answered Sep 21 '22 04:09

johnl