niv / websocket.nim

websockets for nim
http://niv.github.io/websocket.nim/docs/0.1.1/websocket.html
Other
101 stars 25 forks source link

Simulate the network timeout (unplug the network cable), and then restore the network state. The program receiving data is interrupted, and then it seems to be blocked or unresponsive? #72

Open AndrewGPU opened 1 year ago

AndrewGPU commented 1 year ago

It looks like the group is blocked, I don't know how to deal with it

AndrewGPU commented 1 year ago

^CTraceback (most recent call last) /Users/andrew/work/nimsource/wst.nim(36) wst /Users/andrew/.choosenim/toolchains/nim-#devel/lib/pure/asyncdispatch.nim(2005) runForever /Users/andrew/.choosenim/toolchains/nim-#devel/lib/pure/asyncdispatch.nim(1700) poll /Users/andrew/.choosenim/toolchains/nim-#devel/lib/pure/asyncdispatch.nim(1441) runOnce /Users/andrew/.choosenim/toolchains/nim-#devel/lib/pure/asyncdispatch.nim(269) processPendingCallbacks /Users/andrew/.choosenim/toolchains/nim-#devel/lib/pure/asyncmacro.nim(31) readNimAsyncContinue /Users/andrew/.choosenim/toolchains/nim-#devel/lib/pure/asyncmacro.nim(136) readIter /Users/andrew/.choosenim/toolchains/nim-#devel/lib/pure/asyncfutures.nim(392) read /Users/andrew/.choosenim/toolchains/nim-#devel/lib/pure/asyncfutures.nim(371) injectStacktrace /Users/andrew/.choosenim/toolchains/nim-#devel/lib/pure/asyncfutures.nim(353) $ SIGINT: Interrupted by Ctrl-C. Traceback (most recent call last) /Users/runner/work/choosenim/choosenim/src/choosenimpkg/proxyexe.nim(62) proxyexe /Users/runner/work/choosenim/choosenim/src/choosenimpkg/proxyexe.nim(49) main /Users/runner/.choosenim/toolchains/nim-1.6.6/lib/pure/osproc.nim(1248) waitForExit SIGINT: Interrupted by Ctrl-C.

Error: execution of an external program failed: ''/Users/andrew/work/nimsource/wst''

Execute ctrl+c to get the stack

jfilby commented 1 year ago

What I do is catch the exception, wait a bit and then try to reconnect.

AndrewGPU commented 1 year ago

我所做的是捕获异常,稍等片刻,然后尝试重新连接。

我直接捕获了错误,但是貌似没错误,得有一个心跳发送,没有返回才会报错,如果没有发送ping的方法,不会报错,会一直hold,不过我现在已经加上心跳,他活的很好,并且重连也很好