Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client handshake returns error message "Transport unknown" #1577

Closed
Maxwell2022 opened this issue Jun 2, 2014 · 35 comments
Closed

Client handshake returns error message "Transport unknown" #1577

Maxwell2022 opened this issue Jun 2, 2014 · 35 comments

Comments

@Maxwell2022
Copy link

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"
}

@RB-Develop
Copy link

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.

@Maxwell2022
Copy link
Author

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

@alexiskattan
Copy link

+1

@gregtap
Copy link

gregtap commented Jun 6, 2014

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

@Maxwell2022
Copy link
Author

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.

@ghost
Copy link

ghost commented Jun 11, 2014

+1

i'm debugging with fiddler

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

screenshot_1

@gmmateev
Copy link

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

@piascikj
Copy link

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"});

@francoisTemasys
Copy link

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?

@ghost
Copy link

ghost commented Jun 17, 2014

no documents in this update!

@francoisTemasys
Copy link

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}

@ghost
Copy link

ghost commented Jun 17, 2014

@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

@francoisTemasys
Copy link

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

@haih
Copy link

haih commented Jul 10, 2014

same error

@adantart
Copy link

same error here !

@nenadvulic
Copy link

same for me

@yvan01
Copy link

yvan01 commented Jul 23, 2014

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.

@hemstar7
Copy link

same error here !

@crawft
Copy link

crawft commented Aug 5, 2014

+1 :(

@maggialejandro
Copy link

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, BrowserSync/browser-sync#71

@akkunchoi
Copy link

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

@rase-
Copy link
Contributor

rase- commented Oct 6, 2014

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

@rase-
Copy link
Contributor

rase- commented Oct 6, 2014

Closing this in favor of socketio/socket.io-protocol#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. :)

@rase- rase- closed this as completed Oct 6, 2014
@Kernelzero
Copy link

  • same error

@steviesama
Copy link

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.

@Narasimha-Murthy
Copy link

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.

@altanai
Copy link

altanai commented May 2, 2016

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

@rosarionakkocom
Copy link

For Those still looking for an answer for here:

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

@kevinguard
Copy link

@rosarionakkocom That didn't help.

@drekka
Copy link

drekka commented Feb 3, 2017

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.

@afshinm
Copy link

afshinm commented May 19, 2017

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

@darrachequesne
Copy link
Member

@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.

@pathbox
Copy link

pathbox commented Mar 3, 2018

@afshinm Thanks, it works

@darrachequesne
Copy link
Member

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).

@AngelliaX
Copy link

Closing this in favor of socketio/socket.io-protocol#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. :)

it works !!!, my client side is using a lib call elephant.io, and it is using verison of 1.0.0, but my socket.io is using 4.0.0, so i install the socket version 1.0.6 (as i see in the terminal) and the problem is fixed even though i dont know why

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests