socketio / socket.io-protocol

Socket.IO Protocol specification
https://socket.io
506 stars 62 forks source link

How to hand-test the polling transport #15

Closed CGenie closed 3 years ago

CGenie commented 8 years ago

Hi,

My goal is to emit a single message to a socketio server, then quit. I use polling transport, so I do a GET request to /socket.io?t=xxx&transport=polling, this gives me back server response with sid so I make another GET to /socket.io?t=xxx&transport=polling&sid=xxx which responsds with message �40 which, as I understand is engine.io message (code 4), socket.io connect (code 0). Next when I repeat the GET request with sid, curl waits for response, is this proper behaviour?

When I do POST (with sid etc) during that time in another terminal, the server sends engine.io 1 message (close).

How can I emit a message after the handshake?

darrachequesne commented 3 years ago

For future readers:

curl -X GET '<url>/socket.io/?transport=polling'

should return a Engine.IO handshake with a sid field, that will be used in subsequent requests

curl -X GET '<url>/socket.io/?transport=polling&sid=<the sid>'
curl -X POST '<url>/socket.io/?transport=polling&sid=<the sid>" -d '11:42["hello",1]'

For an explanation of the encoding, please see here.

curl -X POST '<url>/socket.io/?transport=polling&sid=<the sid>" -d '1:2'

Please note that the requests must not overlap (you have to close an ongoing GET request before sending a POST request).