Jurc
Jurc

Reputation: 23

Three digit encoding of socket.io messages using python-socketio

I'm currently reverse engineering an application that uses socket.io and engine.io v3 for it's communication. While looking at the websocket messages, I noticed that the messages contain three digit encoding like

420["get-user"]
421["get-config"]
422["get-site"]

According to socket-io-protocol/#exchange-protocol and explanation on this question what-do-these-numbers-mean-in-socket-io-payload, I expected a two digit encoding:

4 -> engine.io "message"

2 -> socket.io "EVENT"

I tested event creation with python-socketio v4:

sio = socketio.Client()
sio.connect('https://localhost:5000', transports=['websocket'])
sio.emit('get-user')

This results in the message: '42["get-user"]' which is not answered by the application.

I tested the manual implementation of this encoding using websocket module directly:

websocket_url = "wss://localhost:5000/socket.io/?transport=websocket&EIO=3"
payload = f'420["get-user"]'
ws.send(payload)

This results in message '420["get-user]' being send and is answered by the application.

What is the meaning of the three digit encoding? How can I implement this with python-socketio?

Upvotes: 0

Views: 26

Answers (0)

Related Questions