'How to determine which message belongs to which request in a websocket?
Recently I have connected to a websocket which will retrieve a request ID with each request.
Upon answering the request, the Websocket Server will incoporate the ID into it's response.
Example:
send (message: "ping", id:1)
response: (result: "pong", id:1)
send (message:"gettime", id:2)
response: (result:"1231435124", id:2)
This was very handy as I might have multiple threads sending/receiving data. Messages would not come in the same order as requested. (eg 1 thread for ping-pong, 1 for queries and one for subscribed data).
Answers could easily be matched to the thread which requested data.
Now I am connecting to another websucket but it does not have such an identifier. How will I be able to match the messages to the according requestor? Opening multiple Websocket connections is not easy due to strict rate limitations and I do not want to risk an IP ban.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
