Http.jl websocket is not connecting after some time - EOFError: read end of file

It is really confusing: After letting julia http server run for some time, the websocket won’t connect any longer, giving EOFError: read end of file

 EOFError: read end of file
│    Stacktrace:
│      [1] (::Base.var"#wait_locked#739")(s::Sockets.TCPSocket, buf::IOBuffer, nb::Int64)
│        @ Base ./stream.jl:947
│      [2] unsafe_read(s::Sockets.TCPSocket, p::Ptr{UInt8}, nb::UInt64)
│        @ Base ./stream.jl:955
│      [3] unsafe_read(c::HTTP.Connections.Connection{Sockets.TCPSocket}, p::Ptr{UInt8}, n::UInt64)
│        @ HTTP.Connections ~/.julia/packages/HTTP/sJD5V/src/Connections.jl:203
│      [4] unsafe_read
│        @ ./io.jl:774 [inlined]
│      [5] unsafe_read(s::HTTP.Connections.Connection{Sockets.TCPSocket}, p::Base.RefValue{UInt16}, n::Int64)
│        @ Base ./io.jl:773
│      [6] read!
│        @ ./io.jl:775 [inlined]
│      [7] read
│        @ ./io.jl:779 [inlined]
│      [8] readframe(io::HTTP.Connections.Connection{Sockets.TCPSocket}, ::Type{HTTP.WebSockets.Frame}, buffer::Vector{UInt8}, first_fragment_opcode::HTTP.WebSockets.OpCode)
│        @ HTTP.WebSockets ~/.julia/packages/HTTP/sJD5V/src/WebSockets.jl:129
│      [9] readframe(io::HTTP.Connections.Connection{Sockets.TCPSocket}, ::Type{HTTP.WebSockets.Frame}, buffer::Vector{UInt8})
│        @ HTTP.WebSockets ~/.julia/packages/HTTP/sJD5V/src/WebSockets.jl:128
│     [10] receive(ws::HTTP.WebSockets.WebSocket)
│        @ HTTP.WebSockets ~/.julia/packages/HTTP/sJD5V/src/WebSockets.jl:681
│     [11] iterate(ws::HTTP.WebSockets.WebSocket, st::Nothing)
│        @ HTTP.WebSockets ~/.julia/packages/HTTP/sJD5V/src/WebSockets.jl:720
│     [12] iterate
│        @ ~/.julia/packages/HTTP/sJD5V/src/WebSockets.jl:718 [inlined]

The weirdest thing is that if I build up a connection from another browser (or private window), it somehow recovers itself…

This is really weird and only happens after several hours of running. So hard to reproduce. Any help what this could be about and how to workaround is highly appreciated.

EDIT: it is still there over night, so it is something stable enough to investigate as soon as it happens.
EDIT: while it is working in a private window, today this didn’t heal the connections from standard browser.

1 Like

@pankgeorg by chance, do you know some help?

This EOFError is thrown constantly for several hours… and I haven’t found a way to let it heal systematically. It just won’t connect the socket

All socket connection requests are running into timeout errors because of this.
EDIT: I understood now that the timeout is causing the EOFError. So why is it running into a timeout? Why is the socket not connecting?

now I came up with an ingenious idea: Closing and restarting the browser. It helped immediately… how weird is that???

found a related issue for my brave browser: WebSocket sometimes fails to reconnect until browser restart or website access from incognito mode · Issue #15410 · brave/brave-browser · GitHub
and another issue: Single websocket won't connect using brave. Works for all other browsers. · Issue #23762 · brave/brave-browser · GitHub

I actually have hundreds of open tabs, and people report that it looks like exhaustion of parallel websocket connections which causes this problem…

At least it seems I know the root cause now