We have an application that requires a connection to a STOMP websocket; each screen in the application contains the logic to connect to the socket. This is working fine, however we have not found a way to tear down the previous STOMP socket. I have tried adding a disconnect step on the OnDestroy step for each screen but when we navigate it pops an exception saying that send failed for a socket in connecting status.
After debugging I see that upon navigation, Screen2 connects before Screen1 disconnects which seems to be the root of the problem. I added a button to the UI to disconnect the socket manually and that works as expected so the function to connect/disconnect works as the barebones level.
I did create a POC using a single page application, but with 30+ screens maintaining state will be a nightmare so the team did not like that solution. I was also able to use an Iframe to keep a single socket active but we lost the ability to debug the client actions on the iframed content. Any suggestions on how to implement without having multiple STOMP sockets open per user?