Communicating with socket.io using sourcemod and socket
Hello, I'm trying to connect to my socket.io server with a plugin using socket(3.0.1)
It works nice when I connected to it with web browser(socket.io client) But it just close the connection throwing close code 1002 when I connected with my plugin. Have you guys any idea or solution? here's my node.js server DEBUG LOG Code:
Thu, 22 Jun 2017 17:20:03 GMT socket.io:socket joined room H6lgVyeHYXKaNQ7cAAAF PHP Code:
Code:
Thu, 22 Jun 2017 17:22:35 GMT socket.io:socket joined room 2yNY-DX-uNWmtmftAAAG |
Re: Communicating with socket.io using sourcemod and socket
WebSockets are not just raw sockets. It's a communications protocol.
|
Re: Communicating with socket.io using sourcemod and socket
Luckily, somebody already did the hard work of implementing the websocket protocol:
https://forums.alliedmods.net/showthread.php?t=182615 |
Re: Communicating with socket.io using sourcemod and socket
Quote:
but it implementing only server-side websockets. It looks more complicated communicating with socket.io server via TCP socket client. perhaps I'm missing something that need to be at very last step of handshake... (ping-pong or something?) thanks for reply |
Re: Communicating with socket.io using sourcemod and socket
Maybe you'd better suited HTTP requests? I make plugin with it, that send data to server, and then recieve response.
|
Re: Communicating with socket.io using sourcemod and socket
Sorry, my reply earlier was way too hasty.
Can you post the handshake headers for the request and response using both your browser and your plugin? I see you have some in your comments, but I'm not sure if that's what you hope to get or what you're actually getting. |
Re: Communicating with socket.io using sourcemod and socket
Quote:
I just want to keep these connected. OK, first(after socket connection) I send a request for getting session id: Code:
GET /socket.io/?clienttype=SRCDS&EIO=3&transport=polling&t=LpRVJRD HTTP/1.1 Code:
HTTP/1.1 200 OK Code:
GET /socket.io/?clienttype=SRCDS&EIO=3&transport=websocket&sid=q6GVx_8byvJDsuGUAAAA HTTP/1.1 Code:
HTTP/1.1 101 Switching Protocols |
Re: Communicating with socket.io using sourcemod and socket
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: PHP Code:
Code:
Socket connected! Code:
$ wscat --listen 8000 |
Re: Communicating with socket.io using sourcemod and socket
1 Attachment(s)
Quote:
Code:
GET /socket.io/?EIO=3&transport=websocket&sid=q6GVx_8byvJDsuGUAAAA HTTP/1.1 Code:
GET /socket.io/?EIO=3&transport=websocket HTTP/1.1 server console outputs: Code:
HTTP/1.1 200 OK https://forums.alliedmods.net/attach...1&d=1498371165 Thank you guys for helping to solve the problem |
Re: Communicating with socket.io using sourcemod and socket
Do you necessarily need socket.io? Possibly try using raw websockets? Implementing stuff like socket.io's rooms etc would be way too complicated anyways. Possibly give raw websockets a try, or if you want some kind of abstraction which is closer to native primus.io: https://github.com/primus/primus
|
All times are GMT -4. The time now is 07:45. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.