Skip to content

Commit

Permalink
Fix websocket disconnection errors (#723)
Browse files Browse the repository at this point in the history
Close #722
  • Loading branch information
tisztamo committed Jun 17, 2021
1 parent 209f10e commit ffee0a0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/WebSockets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,17 @@ end

function Base.close(ws::WebSocket; statuscode::Union{Int, Nothing}=nothing)
if !ws.txclosed
closewrite(ws; statuscode=statuscode)
try
closewrite(ws; statuscode=statuscode)
catch e
e isa Base.IOError || rethrow(e)
end
end
while !eof(ws) # FIXME Timeout in case other end does not send CLOSE?
try
readframe(ws)
catch e
e isa WebSocketError || rethrow(e)
e isa WebSocketError || e isa Base.IOError || rethrow(e)
end
end
close(ws.io)
Expand Down

0 comments on commit ffee0a0

Please sign in to comment.