I have a React/Redux app using React Router for routing.
As part of this app I set up a websocket connection. An issue I'm facing is that when navigating directly to a url, the connection is dropped.
For example:
- User lands on home page at
www.app.com/
- Websocket connection is established.
- User naviagtes to
www.app.com/link
via React Router browserHistory (there is no code to establish any connection on this page). - Connection is maintained.
This works as expected. However:
- User lands on home page at
www.app.com/
- Websocket connection is established.
- User navigates directly to
/link
by entering it in the address bar (or refreshing the page after navigating to it via previous example. - Connection dropped.
Is this expected behaviour? If so are there any Redux/React Router patterns for avoiding it? Do I have to manually re-establish the connection every time?