Skip to content

Commit

Permalink
close amqp connection on error
Browse files Browse the repository at this point in the history
Don't try to continue to read from a client socket in the case of
FrameDecode or general exceptions. Chance is that a CloseOk never will
be receivied and instead new FrameDecode error will be raised again and
again.
  • Loading branch information
carlhoerberg committed Sep 30, 2024
1 parent 5bac463 commit 8e78c73
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/lavinmq/amqp/client.cr
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,14 @@ module LavinMQ
rescue ex : AMQP::Error::FrameDecode
@log.error { ex.inspect_with_backtrace }
send_frame_error(ex.message)
break
rescue ex : IO::Error | OpenSSL::SSL::Error
@log.debug { "Lost connection, while reading (#{ex.inspect})" } unless closed?
break
rescue ex : Exception
@log.error { "Unexpected error, while reading: #{ex.inspect_with_backtrace}" }
send_internal_error(ex.message)
break
end
ensure
cleanup
Expand Down

0 comments on commit 8e78c73

Please sign in to comment.