tiagosiebler / okx-api

Node.js SDK for the OKX APIs and WebSockets, with TypeScript & browser support, integration tests, beautification & more.
MIT License
99 stars 28 forks source link

Running for 3-4 minutes will result in:'Pong timeout - closing socket to reconnect' #81

Open tingshuai opened 1 day ago

tingshuai commented 1 day ago

oxk-api version:^1.4.10; node v20.10.0 as image show:

屏幕截图 2024-11-18 221837

tiagosiebler commented 1 day ago

Hi @tingshuai - can you reproduce this with simple code like this: https://gist.github.com/tiagosiebler/113c7dec34f75603254cff990f36849b

I've tried to force a pong timeout to see if the reconnection logic has any issues, and I don't see any problems:

Screenshot 2024-11-18 at 14 31 24

It recovers successfully and re-subscribes as expected. It's possible that the typeerror is thrown by your code somewhere in your event handler (your callstack within the event handler). Either way, if you can show me how to reproduce it with a simple scenario, I can try to help futher.

tingshuai commented 7 hours ago

can you reproduce this with simple code like this:

I tested the same minimal code that fits my environment on both CodeSandbox and my local machine and found:

  1. On CodeSandbox, reconnection occurs, but it doesn't show the message 'Pong timeout - closing socket to reconnect,' and it takes a longer time for the reconnection issue to arise.
  2. On the local machine, the time it takes for this issue to occur is uncertain; it could be a few minutes, several minutes, or even an hour.
  3. On my local machine, I'm using Windows 11 with Node.js version v20.10.0.
  4. This is the example on CodeSandbox, and this is the code repository I ran on my local machine; the code is identical.