0

I'm starting to build a Vite React application that needs to use Websockets and I was wondering about the architecture of these connections.

For a better explanation, the application contains a HomeView - from this view, the user can access 6 other views when only 3 of them will need a WebSocket connection.

Well, at the beginning for me made sense to connect to websockets when entering one of these 3 views and disconnect when leaving one of these same 3 views.

But is this the best for the app performance?

I question myself about this because the user will freely navigate through all the views. Can happen that the user connects and disconnects the websockets several times in a few seconds. This can lead to some unexpected behaviors.

Is better to always establish a higher level websocket connection, and establish this connection all the time?

Thank you in advance

0 Answers0