streadway / amqp

Go client for AMQP 0.9.1
http://godoc.org/github.com/streadway/amqp
BSD 2-Clause "Simplified" License
4.88k stars 621 forks source link

channel.Confirm hangs #537

Closed 76creates closed 1 year ago

76creates commented 1 year ago

Hello all, Im facing a rather strange issue when trying to call channel.Confirm(true), it hangs forever. Tho what is interesting, and please note that Im no GoLang expert user, is that while debugging I tried adding default case to the *Channel.call method as my debugger was acting out, to my surprise after I added empty default it didn't hang anymore. Please advise.

rabbitmq ran on docker using official image

reproducible code:

package main

import (
    "fmt"

    amqp "github.com/rabbitmq/amqp091-go"
)

func main() {
    connection, err := amqp.Dial("amqp://guest:guest@localhost:5672/")
    if err != nil {
        panic(err)
    }
    defer connection.Close()

    channel, err := connection.Channel()
    if err != nil {
        panic(err)
    }
    defer channel.Close()
    fmt.Println("Channel opened")

    if err := channel.Confirm(true); err != nil {
        panic(err)
    }
    fmt.Println("done")

}

updates on channel.go on github.com/rabbitmq/amqp091-go v1.8.1

diff channel.go channel-default -U 5
--- channel.go  2023-05-30 14:08:08
+++ channel-default     2023-05-30 14:07:53
@@ -197,12 +197,10 @@
                        }
                        // RPC channel has been closed without an error, likely due to a hard
                        // error on the Connection.  This indicates we have already been
                        // shutdown and if were waiting, will have returned from the errors chan.
                        return ErrClosed
-               default:
-                       
                }
        }

        return nil
 }