Skip to content

Websocket disconnect errors instead of handling gracefullyΒ #201

@bryaan

Description

@bryaan

When my websocket client disconnects, the server throws an error:

 Info: 2024-06-04 21:41:58 AppWebSockerServer - WS Client Disconnected
β”Œ Error: 2024-06-04 21:41:59 handle_connection handler error.
β”‚
β”‚ ===========================
β”‚ HTTP Error message:
β”‚
β”‚ ERROR: TaskFailedException
β”‚ Stacktrace:
β”‚  [1] wait
β”‚    @ ./task.jl:352 [inlined]
β”‚  [2] (::Oxygen.Core.var"#17#20"{Oxygen.Core.var"#15#16"{Oxygen.Core.var"#29#31"{Oxygen.Core.var"#40#44"{Oxygen.Core.AutoDoc.var"#2#4"{Oxygen.Core.var"#34#37"{HTTP.Handlers.Router{typeof(HTTP.Handlers.default404), typeof(HTTP.Handlers.default405), Nothing}, Bool, Bool}, HTTP.Handlers.Router{typeof(HTTP.Handlers.default404), typeof(HTTP.Handlers.default405), Nothing}, Vector{typeof(Main.LunaStox.ServerHandlers.CorsMiddleware)}, Dict{String, Tuple}}, Oxygen.Core.AppContext.Service, Bool}, HTTP.Handlers.Router{typeof(HTTP.Handlers.default404), typeof(HTTP.Handlers.default405), Nothing}, String}}})(stream::HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.Connections.Connection{Sockets.TCPSocket}})
β”‚    @ Oxygen.Core ~/.julia/packages/Oxygen/LWjgB/src/core.jl:225
β”‚  [3] #invokelatest#2
β”‚    @ ./essentials.jl:887 [inlined]
β”‚  [4] invokelatest
β”‚    @ ./essentials.jl:884 [inlined]
β”‚  [5] handle_connection(f::Function, c::HTTP.Connections.Connection{Sockets.TCPSocket}, listener::HTTP.Servers.Listener{Nothing, Sockets.TCPServer}, readtimeout::Int64, access_log::Function)
β”‚    @ HTTP.Servers ~/.julia/packages/HTTP/sJD5V/src/Servers.jl:469
β”‚  [6] (::HTTP.Servers.var"#16#17"{Oxygen.Core.var"#17#20"{Oxygen.Core.var"#15#16"{Oxygen.Core.var"#29#31"{Oxygen.Core.var"#40#44"{Oxygen.Core.AutoDoc.var"#2#4"{Oxygen.Core.var"#34#37"{HTTP.Handlers.Router{typeof(HTTP.Handlers.default404), typeof(HTTP.Handlers.default405), Nothing}, Bool, Bool}, HTTP.Handlers.Router{typeof(HTTP.Handlers.default404), typeof(HTTP.Handlers.default405), Nothing}, Vector{typeof(Main.LunaStox.ServerHandlers.CorsMiddleware)}, Dict{String, Tuple}}, Oxygen.Core.AppContext.Service, Bool}, HTTP.Handlers.Router{typeof(HTTP.Handlers.default404), typeof(HTTP.Handlers.default405), Nothing}, String}}}, HTTP.Servers.Listener{Nothing, Sockets.TCPServer}, Set{HTTP.Connections.Connection}, Int64, Oxygen.Core.var"#25#26", ReentrantLock, Base.Semaphore, HTTP.Connections.Connection{Sockets.TCPSocket}})()
β”‚    @ HTTP.Servers ~/.julia/packages/HTTP/sJD5V/src/Servers.jl:401
β”‚
β”‚     nested task error: TaskFailedException
β”‚     Stacktrace:
β”‚      [1] wait
β”‚        @ ./task.jl:352 [inlined]
β”‚      [2] (::Oxygen.Core.var"#18#21"{HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.Connections.Connection{Sockets.TCPSocket}}, Oxygen.Core.var"#15#16"{Oxygen.Core.var"#29#31"{Oxygen.Core.var"#40#44"{Oxygen.Core.AutoDoc.var"#2#4"{Oxygen.Core.var"#34#37"{HTTP.Handlers.Router{typeof(HTTP.Handlers.default404), typeof(HTTP.Handlers.default405), Nothing}, Bool, Bool}, HTTP.Handlers.Router{typeof(HTTP.Handlers.default404), typeof(HTTP.Handlers.default405), Nothing}, Vector{typeof(Main.LunaStox.ServerHandlers.CorsMiddleware)}, Dict{String, Tuple}}, Oxygen.Core.AppContext.Service, Bool}, HTTP.Handlers.Router{typeof(HTTP.Handlers.default404), typeof(HTTP.Handlers.default405), Nothing}, String}}})()
β”‚        @ Oxygen.Core ~/.julia/packages/Oxygen/LWjgB/src/core.jl:223
β”‚
β”‚         nested task error: IOError: stream is closed or unusable
β”‚         Stacktrace:
β”‚           [1] check_open
β”‚             @ ./stream.jl:388 [inlined]
β”‚           [2] uv_write_async(s::Sockets.TCPSocket, p::Ptr{UInt8}, n::UInt64)
β”‚             @ Base ./stream.jl:1074
β”‚           [3] uv_write(s::Sockets.TCPSocket, p::Ptr{UInt8}, n::UInt64)
β”‚             @ Base ./stream.jl:1037
β”‚           [4] unsafe_write(s::Sockets.TCPSocket, p::Ptr{UInt8}, n::UInt64)
β”‚             @ Base ./stream.jl:1120
β”‚           [5] unsafe_write
β”‚             @ ~/.julia/packages/HTTP/sJD5V/src/Connections.jl:132 [inlined]
β”‚           [6] unsafe_write
β”‚             @ ./io.jl:698 [inlined]
β”‚           [7] write(io::IO, x1::Any, xs::Vararg{Any})
β”‚             @ Base ./io.jl:721 [inlined]
β”‚           [8] writeheaders(io::HTTP.Connections.Connection{Sockets.TCPSocket}, m::HTTP.Messages.Response, buf::IOBuffer)
β”‚             @ HTTP.Messages ~/.julia/packages/HTTP/sJD5V/src/Messages.jl:503
β”‚           [9] writeheaders(io::IO, m::HTTP.Messages.Message, buf::IOBuffer)
β”‚             @ HTTP.Messages ~/.julia/packages/HTTP/sJD5V/src/Messages.jl:494 [inlined]
β”‚          [10] startwrite(http::HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.Connections.Connection{Sockets.TCPSocket}})
β”‚             @ HTTP.Streams ~/.julia/packages/HTTP/sJD5V/src/Streams.jl:79
β”‚          [11] (::HTTP.Handlers.var"#1#2"{Oxygen.Core.var"#12#14"{Oxygen.Core.var"#29#31"{Oxygen.Core.var"#40#44"{Oxygen.Core.AutoDoc.var"#2#4"{Oxygen.Core.var"#34#37"{HTTP.Handlers.Router{typeof(HTTP.Handlers.default404), typeof(HTTP.Handlers.default405), Nothing}, Bool, Bool}, HTTP.Handlers.Router{typeof(HTTP.Handlers.default404), typeof(HTTP.Handlers.default405), Nothing}, Vector{typeof(Main.LunaStox.ServerHandlers.CorsMiddleware)}, Dict{String, Tuple}}, Oxygen.Core.AppContext.Service, Bool}, HTTP.Handlers.Router{typeof(HTTP.Handlers.default404), typeof(HTTP.Handlers.default405), Nothing}, String}, Sockets.IPv4, HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.Connections.Connection{Sockets.TCPSocket}}}})(stream::HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.Connections.Connection{Sockets.TCPSocket}})
β”‚             @ HTTP.Handlers ~/.julia/packages/HTTP/sJD5V/src/Handlers.jl:60
β”‚          [12] #15
β”‚             @ Oxygen.Core ~/.julia/packages/Oxygen/LWjgB/src/core.jl:208 [inlined]
β”‚          [13] (::Oxygen.Core.var"#19#22"{HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.Connections.Connection{Sockets.TCPSocket}}, Oxygen.Core.var"#15#16"{Oxygen.Core.var"#29#31"{Oxygen.Core.var"#40#44"{Oxygen.Core.AutoDoc.var"#2#4"{Oxygen.Core.var"#34#37"{HTTP.Handlers.Router{typeof(HTTP.Handlers.default404), typeof(HTTP.Handlers.default405), Nothing}, Bool, Bool}, HTTP.Handlers.Router{typeof(HTTP.Handlers.default404), typeof(HTTP.Handlers.default405), Nothing}, Vector{typeof(Main.LunaStox.ServerHandlers.CorsMiddleware)}, Dict{String, Tuple}}, Oxygen.Core.AppContext.Service, Bool}, HTTP.Handlers.Router{typeof(HTTP.Handlers.default404), typeof(HTTP.Handlers.default405), Nothing}, String}}})()
β”‚             @ Oxygen.Core ~/.julia/packages/Oxygen/LWjgB/src/core.jl:222
β”‚   request =
β”‚    HTTP.Messages.Request:
β”‚    """
β”‚    GET /ws/scanner HTTP/1.1
β”‚    Host: 127.0.0.1:7820
β”‚    User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:124.0) Gecko/20100101 Firefox/124.0
β”‚    Accept: */*
β”‚    Accept-Language: en-US,en;q=0.5
β”‚    Accept-Encoding: gzip, deflate, br
β”‚    Sec-WebSocket-Version: 13
β”‚    Origin: http://localhost:5173
β”‚    Sec-WebSocket-Extensions: permessage-deflate
β”‚    Sec-WebSocket-Key: 7LG0jbS9Ud1oP9uTOFKCrA==
β”‚    DNT: 1
β”‚    Connection: keep-alive, Upgrade
β”‚    Sec-Fetch-Dest: empty
β”‚    Sec-Fetch-Mode: websocket
β”‚    Sec-Fetch-Site: cross-site
β”‚    Pragma: no-cache
β”‚    Cache-Control: no-cache
β”‚    Upgrade: websocket
β”‚
β”‚    """
β”” @ HTTP.Servers ~/.julia/packages/HTTP/sJD5V/src/Servers.jl:483

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions