Anyone here having exper…

2 minute read

Anyone here having experience with SSE / WebSockets?

Responses:

What are you trying to accomplish?

I’m looking at how to push latest updates make to an entity to users that are currently looking at it

Ideally also the first step towards collaborative editing on that entity

So in my data model I have “meetings” and multiple users can participate and take notes collaboratively. So when one user makes a change, others should see those without having to refresh

Front is Angular & back is using NestJS. I saw that Nest has support for WebSockets but not for SSE (yet). SSE is simpler, but i’m wondering about issues with the connections limit

Are you using wss directly? I have always done this with <http://socket.io socket.io>
If I do choose WebSockets, I’ll probably use <http://socket.io socket.io>

Give me a bit I can send you some articles

Cool, thanks

For my poc I’m going to ignore the high availability requirements, but I guess that later on I’ll need something like Redis pub/sub to support HA/load balancing

Fun stuff :wink:

Yea exactly, we used redis and redis lock + wss for a real time auction platform

If you are running more then one server you need to deal with sending the message to all instances

Because client x on server x can’t see user y on server y

Yep indeed that’s what I thought about

And how did you implement this? WSS exposed on all instances and all also listening to a queue to know what to push to WSS clients?

Or do instances just push towards a queue and “something else” handles WSS connections & pushes when there are events to push?

I guess it doesn’t change much; probably a question of architecture / HA requirements

Nestjs has some nice stuff built in for wss. We had redis query and Mongodb and the wss on server listen to a room for each item

And the top bid was saved to redis

And then updated across all sockets

Wss in nestjs end up being tiny modules. The first time I used socket was with angularjs haha it was a massive undertaking back then

Okok, thanks for sharing! :slightly_smiling_face:

Indeed, it was messier a few years back. <http://Socket.io Socket.io> seems approachable enough and indeed Nest has nice support it seems

I would say try playing with a really simple example

Like just push a single entry without the users and see how it flows

Yup yup, baby steps. At first I’m just plugging a dummy button and listener on the client side, with a ping request on the back-end :wink:

Later I’ll need to integrate the WSS client with NGRX to push updates into the store

Updated: