Azure / go-amqp

AMQP 1.0 client library for Go.
https://github.com/Azure/go-amqp
MIT License
108 stars 59 forks source link

Connecting to ActiveMQ Classic v6.1.1 fails #328

Closed SamTV12345 closed 4 months ago

SamTV12345 commented 4 months ago

I try to use your sdk to connect to ActiveMQ and read and write messages. Unfortunately ActiveMQ does not allow a connection. It says

WARN | Connection attempt from non AMQP v1.0 client. AMQP,0,1,0,0

I used:

    conn, err := amqp.Dial(context.Background(), "amqp://localhost:5672", nil)
SamTV12345 commented 4 months ago

Found the error. For whatever reason ActiveMQ declines the connection and shows this generic message. There is no version conflict. You just need to have the SASLType set. I set mine to:

conn, err := amqp.Dial(context.Background(), "amqp://localhost:5672", &amqp.ConnOptions{
    SASLType: amqp.SASLTypeAnonymous(),
})
ansd commented 2 months ago

Nice! The client needs to start the handshake with AMQP,3,1,0,0 where the 3 means SASL security layer. (The SASL security layer is also required in RabbitMQ 4.0 btw.)