Socket.io: Client handshake returns error message "Transport unknown"

Created on 2 Jun 2014  Â·  34Comments  Â·  Source: socketio/socket.io

I was trying to initialize a handshake, following the specs I've found at LearnBoost/socket.io-spec. Sometime I found that it has to be done with a POST request, sometime with GET. I've tried both of them and they both returned the same error:

GET http://acme.local:3700/socket.io/1
or
POST http://acme.local:3700/socket.io/1

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

Most helpful comment

I've encountered same error on socket.io v1.1.0.

I added a follow line at server side script, then I fixed this problem.
io.set('transports', ["websocket", "polling"]);

Errors I encountered:

  • GET /socket.io returns Transport unknown.
  • DEBUG=* node-dev app.js prints a lot of unknown transport polling.

I refer http://stackoverflow.com/questions/23962047/socket-io-v1-0-x-unknown-transport-polling

All 34 comments

This is a problem for me as well. I can't run benchmarks for testing the Socket.io performance on my server due to this error.

I see this is not a local error seeing that the demo chat application on the Socket.io homepage has the same issue. http://chat.socket.io/socket.io/1 returns the exact same response.

It's due to the version of socket.io. I had to downgrade to v0.9.x because I could not find any documentation about the way to perform handshake with version v1.0.x

+1

Make sur that the client and server libs are 1.0.x

I'm not using the javascript client but a custom PHP client. So it needs to handle the handshake. I'll wait to get some documentation about it or might have a look, if I have time, how the javascript client is actually performing the handshake.

+1

i'm debugging with fiddler

chat.socket.io not using 'chat.socket.io/socket.io/1'

screenshot_1

I experience the same issue when I manually send the handshake request.

Some more documentation on how to accomplish a handshake with 1.0.x would be very helpful. I'm receiving the same error. I can't find any of the query params on the server side that I applied using

var socket = io("http://localhost:8080", {query:{bla:"bla"});

or

var socket = io("http://localhost:8080", {query:"bla=bla"});

Same problem here using a C++ library.
Doing a POST request to the server like this:

Send Handshake Post request...:
POST /socket.io/1/ HTTP/1.1
Accept: */*
Content-Type: text/plain
Host: localhost
Connection: Keep-Alive

It returns:

[ERRFMT] Bad Request
response: {"code":0,"message":"Transport unknown"}

What have changed?

no documents in this update!

I don't know if that would help:
When requesting:

GET /socket.io/1/?EIO=2&transport=polling HTTP/1.1
Accept: */*
Content-Type: text/plain
Host: localhost
Connection: Keep-Alive

On 0.9.4:

response: 9svmBRkeQuECcpw6ZGPK:60:60:websocket,htmlfile,xhr-polling,jsonp-polling

On 1.0.4:

response:   �0{"sid":"ySaqnVO4pJajP_TfAAAM","upgrades":["websocket"],"pingInterval":25000,"pingTimeout":60000}

@francoisTemasys

i testing with chat example source.

first. get sid

Send: Return Code: 0x00000000
GET /socket.io/?EIO=2&transport=polling&t=1402968982931-0 HTTP/1.1
Accept: */*
Referer: http://localhost:3000/
Accept-Language: ko-KR
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
Host: localhost:3000
DNT: 1
Connection: Keep-Alive

second. request same url with sid, again, handshake is done

Send: Return Code: 0x00000000
GET /socket.io/?EIO=2&transport=polling&t=1402968982946-1&sid=UwY0AcBHl84hz1FvAAAb HTTP/1.1
Accept: */*
Referer: http://localhost:3000/
Accept-Language: ko-KR
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
Host: localhost:3000
DNT: 1
Connection: Keep-Alive
Cookie: io=UwY0AcBHl84hz1FvAAAb

third. connect to websocket, but i can't succeed.. socket.io not responses heartbeat.

Send: Return Code: 0x00000000
GET /socket.io/?EIO=2&transport=websocket&sid=UwY0AcBHl84hz1FvAAAb HTTP/1.1
Origin: http://localhost:3000
Sec-WebSocket-Key: t1eDysQI92E+9v3n0mq6sA==
Connection: Upgrade
Upgrade: Websocket
Sec-WebSocket-Version: 13
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
Host: localhost:3000
DNT: 1
Cache-Control: no-cache
Cookie: io=UwY0AcBHl84hz1FvAAAb

I tried here is the output on 1.0.4:

First GET:

GET /socket.io/1/?EIO=2&transport=polling HTTP/1.1
Accept: */*
Content-Type: text/plain
Host: localhost
Connection: Keep-Alive

RESPONSE:
[ERRFMT] OK
response:   �0{"sid":"AmcxWuqqPAFapV74AAAC","upgrades":["websocket"],"pingInterval":25000,"pingTimeout":60000}

Second Query with the sid:

GET /socket.io/1/?EIO=2&transport=polling&sid=AmcxWuqqPAFapV74AAAC HTTP/1.1
Accept: */*
Content-Type: text/plain
Host: localhost
Connection: Keep-Alive

RESPONSE:
[ERRFMT] OK
response: �40

same error

same error here !

same for me

Hey, this might help, you can set the response to return plain text by setting b64=true in the request. (you also need to set the transport in the request)

For example:
https://localhost:3030/socket.io/?EIO=2&transport=polling&t=1406120775060-0&b64=true

This returns (content-type:text/plain)
97:0{"sid":"g75H5D6feFrj9cCDAAAB","upgrades":["websocket"],"pingInterval":25000,"pingTimeout":60000}

Also, the packet returned seems to have the following format:

In the above example
Message length = 97
Type = 0 (Open)
Data = {"sid":"g75H5D6feFrj9cCDAAAB","upgrades":["websocket"],"pingInterval":25000,"pingTimeout":60000}

Hope it helps, but you should know I'm new to socket.io so there may be other adjustments you need to make that I'm not aware of.

same error here !

+1 :(

Same here, I'm using socket.io v1.0.6 on both client and server..
I find out that the browser-sync ~0.8.2 (uses socket.io 0.8.7) was causing the problem, https://github.com/shakyShane/browser-sync/issues/71

I've encountered same error on socket.io v1.1.0.

I added a follow line at server side script, then I fixed this problem.
io.set('transports', ["websocket", "polling"]);

Errors I encountered:

  • GET /socket.io returns Transport unknown.
  • DEBUG=* node-dev app.js prints a lot of unknown transport polling.

I refer http://stackoverflow.com/questions/23962047/socket-io-v1-0-x-unknown-transport-polling

We'll definitely work on adding more documentation about the handshake to socket.io-protocol, where I feel like this issue belongs.

Closing this in favor of https://github.com/Automattic/socket.io-protocol/issues/10.

If this issue occurs when using socket.io (not a custom implementation) what @coulix said is likely the fix: make sure that the client and server are of the same version. Please do open another issue about it if this doesn't help. :)

  • same error

I actually got through the first 2 completing the handshake, and the on connection emit actually fires and I pick it up in the serial monitor of my Arduino, but the third connection upgrade request I get bad request. So frustrating.

when i try open socket my getting error message is
2016-03-25 17:47:36.043 szx[3499:103945] ERROR: handshake failed ... The request timed out.

since im also facing this , i guess its not fixed uptill now . im using "socket.io": "^1.4.5",

For Those still looking for an answer for here:

https://www.npmjs.com/package/passport.socketio

@rosarionakkocom That didn't help.

Just hit this as well. Trying various options. Am just lying to test out a server I've built and using PAW as a client.

I fixed this problem by adding this setting to my socket.io server:

var socket = io({
  transports: [
    'websocket', 
    'flashsocket', 
    'htmlfile', 
    'xhr-polling', 
    'jsonp-polling', 
    'polling'
  ]
});

read more here: http://stackoverflow.com/a/24244413/375966

@afshinm please note that, as documented there, the order in transports options is important:

Note: The order is important. By default, a long-polling connection is established first, and then upgraded to WebSocket if possible. Using ['websocket'] means there will be no fallback if a WebSocket connection cannot be opened.

@afshinm Thanks, it works

Please note that since socket.io version 1.x, the only valid values for transports are:

  • websocket
  • polling

All the other values in @afshinm 's answer won't be used (in fact, only websocket transport will be used in that case).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dmuth picture dmuth  Â·  3Comments

karmac2015 picture karmac2015  Â·  3Comments

kootoopas picture kootoopas  Â·  4Comments

chfeizy picture chfeizy  Â·  3Comments

gCurtisCT picture gCurtisCT  Â·  4Comments