Search code examples
goibm-mqamqp

EOF when connecting to IBM MQ with AMQP 1.0 from golang


I've installed IBM MQ (8.0.0.4) on a local Windows VM and followed the instructions in the docs to enable AMQP (https://www.ibm.com/support/knowledgecenter/en/SSFKSJ_8.0.0/com.ibm.mq.con.doc/tamqp_creating.htm), and also disabled authentication since this is just a local development environment. With that done, I am able to connect from my host OS using the node.js sample in IBM's mqlight package:

>npm install mqlight
...
>node node_modules/mqlight/samples/recv.js -s amqp://windows-10:5672
Connected to amqp://windows-10:5672 using client-id recv_126117c
Subscribed to pattern: public

However, when attempting to connect from a golang app using vcabbage/amqp (version 0.12.5), it returns an EOF error on the attempt to dial the host. Minimal example:

package main

import (
    "fmt"

    "pack.ag/amqp"
)

func main() {
    _, err := amqp.Dial("amqp://windows-10:5672")
    fmt.Println(err) // EOF
}

Nothing is appearing in the IBM MQ error logs.

Unfortunately Google does not turn up any relevant results for connecting to IBM MQ via AMQP 1.0 in golang, so I'm stuck. Does anyone have any ideas?


Solution

  • So the solution is apparently to use SASL Anonymous mode; this allows the client to connect.

    package main
    
    import (
        "fmt"
    
        "pack.ag/amqp"
    )
    
    func main() {
        _, err := amqp.Dial("amqp://windows-10:5672", amqp.ConnSASLAnonymous())
        fmt.Println(err) // nil
    }
    

    If anybody wants to try to make it work in "normal" mode, it appears that IBM MQ was closing the channel as soon as the initial header packet was sent. The EOF was bubbling up from the receiving goroutine in any case.