Open aboisvert opened 6 years ago
Something occurred to me after filing this issue: Should I be using runForever()
instead of waitFor server.serve()
? That seems to be the common patterns I see, e.g., for Jester examples.
@aboisvert with runForever()
async event loop will run FOREVER, and with waitFor server.serve()
event loop will run until serve()
returns (or throws an error)
In theory they should be the same, as server.serve
should go on indefinitely, isn't it? Here the problems seems to be that the server does not survive bad clients. I would try putting a reverse proxy such as Nginx in front of it, it may help with connection problems from the clients
I'm using AsyncHttpServer (Nim 0.18.0) together with Rosencrantz (0.3.2).
My main looks like:
where
handler
is a composition of GET + POST Rosencrantz routes.About once a day, my server will die with a "Connection timed out" error message:
I've tried catching this exception and calling
waitFor server.serve(Port(8080), handler)
again however, I'll get various other issues doing so, such as "Address already in use", up to eventually running out of file descriptors.It does not appear that I can effectively 1) keep my server running for long and 2) resume serving requests after a failure other than completely terminating the process, which is less than ideal because I lose some state and have some downtime between failure and recovery.
It seems the AsyncHttpServer should be resilient to these "Connection timed out" conditions and not raise an exception to begin with.