Closed hiteshjasani closed 5 years ago
Try updating websockets to #head, I fixed this bug IIRC: nimble install websockets@#head
Same error. Here's what I did.
nimble install --verbose websocket@#head
-- Note you have an extra s
char in your command.nimble list -i
shows websocket [#head, 0.3.5]
as installed..nimble
dependency section to requires "nim >= 0.19.0", "websocket#head"
time ./buggy_websocket 120000
results in the same IndexError
after ~54 seconds.Seems like a bug with our websocket client implementation. I tried looking into it but your code fails with ".... connection failed!" and a "server did not reply with a websocket upgrade:" exception. Not sure why that might be, any ideas?
@dom96 Those errors indicate the SSL connection didn't complete. I was actually getting that error myself and was able to bypass it by instantiating the SslContext myself. Try making the following change to see if this works for you.
Change this
let sslCtx = newContext(protSSLv23, verifyMode = CVerifyNone)
doAssert(not sslCtx.isNil, "Failed to initialize SSL context")
let ws = waitFor newAsyncWebsocketClient(WS_HOST, WS_PORT,
WS_PATH, WS_SSL,
ctx = sslCtx)
to
let ws = waitFor newAsyncWebsocketClient(WS_HOST, WS_PORT,
WS_PATH, WS_SSL)
It'll use the default SslContext created in websocket/client.nim
, which is protTLSv1
.
BTW, can we reopen this issue? I'm still seeing the same behavior with the new code merged from #53.
Nim Compiler Version 0.19.2 [MacOSX: amd64], Compiled at 2018-12-31 websocket [0.3.5]
If you run the following websocket client program you'll see that for any sleep time argument longer than 54000 (millis), it will get an
IndexError
at approx 54 seconds into the run.time ./buggy_websocket 10000
time ./buggy_websocket 20000
time ./buggy_websocket 120000
time ./buggy_websocket 240000
Some thoughts:
IndexError
onwebsocket.close()
. Is there a better way to close the socket without getting the error?Example stack trace