문제

Usecase:

  1. I have connected to server via Websocket.
  2. Some how I got disconnected.
  3. Now server have something to deliver using same websocket.
  4. after few seconds I connected again.(My question raise here.)

When I(Client) connected again. (Is there any way that I can reutilize same websocket connection I was connected earlier? ) Or Every time I have to reconnect using new websocket connection only?

도움이 되었습니까?

해결책

Answer to your question heavily relies on the implementations. From what I know, it is possible, but..

When WebSocket support is implemented on top of Servlet 3.1 API, it might not be possible, because I don't think that servlet implementation is able to reuse upgraded connection. Additionally, it also depends on the way how the connection was closed - closing the underlying TCP connection is valid close from WebSocket RFC point of view and then you don't have anything to reuse.

My qualified guess would be (if you are implementing client) - if the connection is left intact after close is detected, you might try to reuse it. Otherwise you need to open the new one.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top