I am integrating spring web-sockets into a web application. And I want to use this for two calls that are taking really long time in ajax. As per my understanding I see there are different design choices about how do I go about with this. I am thinking about the following, can you let me know what would be the best option and if so why
1) Open a socket connection once user logs into the application through SockJS and use this connection to send messages and to subscribe for the two calls that I want to make. One of the question I had with this design is that if the user just closes the browser will the socket connection stay open?
2) Open a socket connection for each call and close it after recieving the message but here it takes up lots of resources to establish a connection each time.
I am pretty new to spring-websocket, SockJS and STOMP stuff so let me know my understanding is wrong anywhere?
Thanks in advance