News for hackers. Stuff that matters.
Re:Ask HN: How do you scale WebSocket? by blablablub on Wednesday June 29, 2022 @06:09PM (#31926293)
" the connection is not getting established all the time" Which connection does not get established? The webhook connection to your backend or the websocket connection to your backend? Or do you get a webhook response, but failing to send a response via websocket?
Re:Ask HN: How do you scale WebSocket? by ravirajx7 on Thursday June 30, 2022 @01:38AM (#31929007)
It's the websocket connection which is not getting established. Webhook response is a simple Post request and it's coming fine. The problem here is sometimes this webhook response comes to that particular instance where the websocket connection was not established with the client.Ideally I would be happy if this response comes to both of the instance through some configuration on loadbalancer.
Re:Ask HN: How do you scale WebSocket? by blablablub on Thursday June 30, 2022 @04:01AM (#31929843)
As per your other answer, websocket connections are established just fine

"Now, whenever a new Webhook response comes ... it doesn't have information regarding which instance was used earlier for making the websocket connection, it may send request to one of the instance where the connection was not established and thus our backend is not able to process this request from this particular instance."

just include the internal ip of the websocket connection to the data you send to your billing operator and then forward the post request appropiately.

Re:Ask HN: How do you scale WebSocket? by blablablub on Thursday June 30, 2022 @03:57AM (#31929812)
Easiest way is to check on the client side if the websocket connection is established, if not, just try to reconnect after a couple of seconds. Maybe there is a problem on the backend that dns is faster than establishing a new instance, so retrying is your best option.