質問

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