Quote:
Originally Posted by Fyren
I tested your code using " wscat --listen" for the server and it does seem to work right. Maybe your websocket server is expecting different data to be sent first?
I did make a few small changes, but I don't think anything changed that matters:
|
I got this. setting
sid parameter in handshake request was the problem
Code:
GET /socket.io/?EIO=3&transport=websocket&sid=q6GVx_8byvJDsuGUAAAA HTTP/1.1
Host: 127.0.0.1:8000
Connection: Upgrade
Upgrade: WebSocket
Origin: http://127.0.0.1:8000/
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: YW4gc3JjZHMgd3MgdGVzdA==
working request:
Code:
GET /socket.io/?EIO=3&transport=websocket HTTP/1.1
Host: 127.0.0.1:8000
Connection: Upgrade
Upgrade: WebSocket
Origin: http://127.0.0.1:8000/
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: YW4gc3JjZHMgd3MgdGVzdA==
server console outputs:
Code:
HTTP/1.1 200 OK
Content-Type: application/octet-stream
Content-Length: 101
Access-Control-Allow-Origin: *
Set-Cookie: io=koZVmcSaYqjz_Yn5AAAF; Path=/; HttpOnly
Date: Sun, 25 Jun 2017 06:04:51 GMT
Connection: keep-alive
Room(Session) ID: koZVmcSaYqjz_Yn5AAAF
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: g0G7yI0fUu+ZAN+kTvfCOjCqOJg=
ACCEPT-KEY: g0G7yI0fUu+ZAN+kTvfCOjCqOJg=
갫0{"sid":"2_Q9DdgHvOzEwalvAAAG","upgrades":[],"pingInterval":25000,"pingTimeout":60000}
?40
sendhello
Sending websocket frame
42["sendchat", "Hello, Socket.io!"]
You received a data:
?42["updatechat",null,"Hello, Socket.io!"]
web outputs:
Thank you guys for helping to solve the problem