gateio / gatews

Gate Websocket V4 SDK
89 stars 35 forks source link

Websockets being closed on infrequently traded instruments #13

Closed quantnik closed 2 years ago

quantnik commented 2 years ago

I've noticed that on some instruments, the server side closes the websocket after a while.

This is despite:

1) having the "infrastructure" level ping/pong enabled 2) explicitly doing the application level ping/pong every 30 seconds.

This mostly happens on the websocket when subscribing to trades, and only on infrequently traded instruments

Is this expected?

Thank you.

revilwang commented 2 years ago

Which WebSocket server endpoint are you referring to? Just to make it clear, as we have 2 versions running

quantnik commented 2 years ago

Apologies -should have mentioned - this is v4

revilwang commented 2 years ago

Have you tried using SDK in this repo? We've tested the client connection with the SDK and we barely saw connection lost.

The server will do the following to make sure active clients will not be closed easily.

  1. Protocol-layer ping sent with 3 seconds timeout waiting for client response. If timeout for 3 times, client is closed
  2. Even if the ping requests timeout, before the 3 times reached. Protocol-layer ping or application spot.ping received from the client, the timeout will be reset.