Skip to content
This repository has been archived by the owner on Dec 14, 2020. It is now read-only.

Commit

Permalink
Handle server initiated connection close.
Browse files Browse the repository at this point in the history
Server initaited close frames were being treated as an unexpected frame
and did not correctly propagate the contained error to the user.

Resolves #151
  • Loading branch information
vcabbage committed Jan 30, 2019
1 parent eeac921 commit d48c91e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ var (
ErrTimeout = errors.New("amqp: timeout waiting for response")

// ErrConnClosed is propagated to Session and Senders/Receivers
// when Client.Close() is called.
// when Client.Close() is called or the server closes the connection
// without specifying an error.
ErrConnClosed = errors.New("amqp: connection closed")
)

Expand Down Expand Up @@ -358,6 +359,15 @@ func (c *conn) mux() {
)

switch body := fr.body.(type) {
// Server initiated close.
case *performClose:
if body.Error != nil {
c.err = body.Error
} else {
c.err = ErrConnClosed
}
return

// RemoteChannel should be used when frame is Begin
case *performBegin:
session, ok = sessionsByChannel[body.RemoteChannel]
Expand Down

0 comments on commit d48c91e

Please sign in to comment.