ibm-messaging / mq-golang

Calling IBM MQ from Go applications
Apache License 2.0
168 stars 60 forks source link

Don`t connect to server. "MQCONNX: MQCC = MQCC_FAILED [2] MQRC = MQRC_CONNECTION_BROKEN [2009] #193

Closed papoff8295 closed 2 years ago

papoff8295 commented 2 years ago

Hello! I have a temporal activity with ibm_mq go, deployed in a kubernetes. My client:

`func Start(ctx context.Context, sms dto.ErrorSms) error {

logger := utils.FnGetActivityLogger(ctx)

qMgrName := "mocksibmmqdev76bb99c8cchqjwt"
//qMgrName := "DEV.QUEUE.1"
topicString := "DEV.QUEUE.1"

cno := ibmmq.NewMQCNO()
csp := ibmmq.NewMQCSP()
csp.AuthenticationType = ibmmq.MQCSP_AUTH_USER_ID_AND_PWD
csp.UserId = "admin"
csp.Password = "passw0rd"

cd := ibmmq.NewMQCD()
cd.ConnectionName = "172.16.37.112(1414)"

cno.ClientConn = cd
cno.CCDTUrl = "172.16.37.112:1414"
cno.ApplName = "ibm mq activity"
cno.SecurityParms = csp
qMgrObject, err := ibmmq.Connx(qMgrName, cno)
if err != nil {
    logger.Info("ibmMqActivity: output error", map[string]any{"MQReturn": err.(*ibmmq.MQReturn).Error()})
    return err
} else {
    fmt.Printf("Connected to queue manager %s\n", qMgrName)
    defer disc(qMgrObject)
}

// Open of the topic object
if err == nil {
    // Create the Object Descriptor that allows us to give the topic name
    mqod := ibmmq.NewMQOD()

    // We have to say how we are going to use this object. In this case, to PUBLISH
    // messages. That is done in the openOptions parameter.
    openOptions := ibmmq.MQOO_OUTPUT

    // When opening a Topic, MQ has a choice of whether to refer to
    // the object through an ObjectName value or the ObjectString value or both.
    // For simplicity, here we work with just the ObjectString
    mqod.ObjectType = ibmmq.MQOT_TOPIC
    mqod.ObjectString = topicString

    topicObject, err = qMgrObject.Open(mqod, openOptions)
    logger.Info("ibmMqActivity: output error", map[string]any{"PARAMS": topicObject})
    if err != nil {
        logger.Info("ibmMqActivity: output error", map[string]any{"MQOD": mqod, "MQOO_OUTPUT": openOptions, "error": err})
        return err
    } else {
        defer func(object ibmmq.MQObject) {
            err := closeTopic(object)
            if err != nil {
                logger.Info("ibmMqActivity: output error", map[string]any{"MQObject": object, "error": err})
            }
        }(topicObject)
    }
}

..... } return nil }`

And i get Error at ibmmq.Connx(qMgrName, cno) - "Error":"MQCONNX: MQCC = MQCC_FAILED [2] MQRC = MQRC_CONNECTION_BROKEN [2009] What am I doing wrong?

ibmmqmet commented 2 years ago

For a start, you seem to be setting the ccdtUrl to the same as the ConnName. If you're got a CCDT, then you don't need a connname, and the setting should be a real URL, something like "http:///". You may also find more information in a client-side error log, AMQERR01.LOG.

papoff8295 commented 2 years ago

Thanks for the answer! I'll take a look! CCDT - I experimented .. tried different things

papoff8295 commented 2 years ago

Mark, tell me please, what version of the library do you recommend to use for client and server 9.2?

ibmmqmet commented 2 years ago

The latest version should work fine

papoff8295 commented 2 years ago

just found out that our related team has a server version of 7.5.(!!) Which version of the library do you recommend using?

ibmmqmet commented 2 years ago

I'd recommend updating the server.

This package has a minimum version of the MQ V8 client to compile, but even that is way out of support. Any client version OUGHT to be able to connect to that level of qmgr, but you might not be able to use TLS as there may not be any matching protocols/ciphers available. And other features like authentication will not be available either.

papoff8295 commented 2 years ago

Thanks for the answer! close)