Joseki-jl/Joseki.jl

Connection timeout

Closed this issue · 1 comments

Hello,
I found issue with connection timeout.
I have one long task that should be launched through endpoint, but after about 30 minutes I get such error:

Error: (Base.IOError("read: connection timed out (ETIMEDOUT)", -110), 
Base.StackTraces.StackFrame[try_yieldto(::typeof(ensure_rescheduled), ::RefValue{Task}) at 
event.jl:196, wait() at event.jl:255, wait(::Condition) at event.jl:46, wait_readnb(::TCPSocket, 
::Int64) at stream.jl:368, eof at stream.jl:61 [inlined], read_to_buffer(::Transaction{TCPSocket}, 
::Int64) at ConnectionPool.jl:206, readuntil(::Transaction{TCPSocket}, ::Function, ::Int64) at 
ConnectionPool.jl:226, readuntil at ConnectionPool.jl:224 [inlined], 
readheaders(::Transaction{TCPSocket}, ::Request) at Messages.jl:471, 
startread(::Stream{Request,Transaction{TCPSocket}}) at Streams.jl:153, 
#handle_transaction#12(::Bool, ::Function, ::##4#5{Router{Symbol("##365")}}, 
::Transaction{TCPSocket}) at Servers.jl:340, (::#kw##handle_transaction)
(::NamedTuple{(:final_transaction,),Tuple{Bool}}, ::typeof(handle_transaction), ::Function, 
::Transaction{TCPSocket}) at none:0, handle_connection(::Function, ::Connection{TCPSocket}, 
::Server{Nothing,TCPServer}, ::Int64, ::Int64) at Servers.jl:299, macro expansion at Servers.jl:257 [inlined], 
(::##8#9{##4#5{Router{Symbol("##365")}},Server{Nothing,TCPServer},RefValue{Int64},Int64,Int64,Bool,Connection{TCPSocket},Int64})() at task.jl:259])
└ @ HTTP.Servers ~/.julia/packages/HTTP/ceBZF/src/Servers.jl:263

And endpoint is starting again by itself.
GET request to: /main at 2019-08-27T13:54:15.812

Is it possible to set the connection timeout = Inf?

The only timeout setting in the HTTP.jl server is the one mentioned here which closes the connection after 60 seconds without receiving new data. It looks like you're losing the connection itself and not being timed out on the server side.

For any process that takes more than a few seconds, I would strongly recommend setting up a polling system. There's a long description of this in this Stackoverflow question but basically you should send a 202 response when the client submits a request, and return a different API endpoint where the client can check on the status every few minutes.

PS: I took the liberty of encasing your error message in three backticks to make it easier to read.