Websocket "Identifier values have to increase."

Hey there, I hope this isn’t a stupid question or mentioned in another topic, but I have a problem where I can’t find a solution.
I am using Websockets in a frontend and trying for example to subscribe to all states by using {“type”:“get_states”,“id”:3}. The Problem is, the callback from the server is: {“id”: 3, “type”: “result”, “success”: false, “error”: {“code”: 1, “message”: “Identifier values have to increase.”}}. Well and this code with this message also appears, when I am trying to set a value for a device, e.g. by using {“type”:“call_service”,“domain”:“climate”,“service”:“set_temperature”,“service_data”:{“temperature”:17,“entity_id”:“climate.xyz”},“id”:11}, but the answer from the server is also: {“id”: 11, “type”: “result”, “success”: false, “error”: {“code”: 1, “message”: “Identifier values have to increase.”}}. Any ideas?

Ok I’ve understood the mechanism and found a solution. If anyone runs into the same problem: The id of the call is generic upcounting, means if you send a request, the id of the request has to be HIGHER than the previous request, never smaller or equal. Then everything works fine.

But this isn’t just YOUR requests, its ALL requests. How do you determine what the next usable ID if you connect to the WS API mid-stream?