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

value out of range: -1 #10

Closed Krognol closed 6 years ago

Krognol commented 6 years ago

This error can appear anywhere between a few hours to a few days, but it's always the same and I can't find the cause for it.

value out of range: -1
  recv's lead up to read of failed Future:
    Traceback (most recent call last)
    main.nim(93)             main
    asyncdispatch.nim(271)   waitFor
    asyncdispatch.nim(298)   poll
    asyncdispatch.nim(426)   :anonymous
    asyncfutures.nim(109)    complete
    asyncmacro.nim(34)       cb
    asyncmacro.nim(334)      appeaseSslIter
    asyncfutures.nim(109)    complete
    asyncmacro.nim(34)       cb
    asyncnet.nim(388)        recvIter
    system.nim(2662)         sysFatal
  recvFrame's lead up to read of failed Future:
    Traceback (most recent call last)
    main.nim(93)             main
    asyncdispatch.nim(271)   waitFor
    asyncdispatch.nim(298)   poll
    asyncdispatch.nim(426)   :anonymous
    asyncfutures.nim(109)    complete
    asyncmacro.nim(34)       cb
    asyncmacro.nim(334)      appeaseSslIter
    asyncfutures.nim(109)    complete
    asyncmacro.nim(34)       cb
    asyncnet.nim(388)        recvIter
    system.nim(2662)         sysFatal
    [[reraised from:
    main.nim(93)             main
    asyncdispatch.nim(271)   waitFor
    asyncdispatch.nim(298)   poll
    asyncdispatch.nim(426)   :anonymous
    asyncfutures.nim(109)    complete
    asyncmacro.nim(34)       cb
    asyncmacro.nim(334)      appeaseSslIter
    asyncfutures.nim(109)    complete
    asyncmacro.nim(50)       cb
    asyncfutures.nim(156)    fail
    asyncmacro.nim(34)       cb
    asyncmacro.nim           recvFrameIter
    asyncfutures.nim(220)    read
    ]]
dom96 commented 6 years ago

Possibly a bad client. You may wish to try putting your service behind a reverse proxy like nginx.

Krognol commented 6 years ago

Seems strange to me that I'd have to go through those hoops just to have it stay running without problems.

Could it be something else?

niv commented 6 years ago

Looking at the stack trace, I'm not immediately seeing any websockets-related frames in it. Could this be a issue in the asyncnet module?

That said, this library will raise exceptions when something is wrong with the data that the client sent you. You need to handle them properly if you want your server to stay up; i.e. try/except around recvFrame and friends. You can then do whatever you wish with their connection. No need to put a reverse proxy in front (though it may be a good idea regardless).

If this doesn't solve your issue, please post the relevant code snippet to have a look at.

Krognol commented 6 years ago

I'll re-post the issue in Nim's repo and close it here.