ibm-messaging / mq-golang

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

Runtime Error #169

Closed 2020testuser closed 3 years ago

2020testuser commented 3 years ago

Can anyone please help me? When I run the put program as below in MAC, I get the below error? Thanks in advance! go run amqsput.go QName1 QMgr1 `../../../../go/pkg/mod/github.com/ibm-messaging/mq-golang/v5@v5.2.0/ibmmq/mqi.go:54:10: fatal error: 'cmqc.h' file not found

include `

ibmmqmet commented 3 years ago

Not finding cmqc.h is a compile problem, not runtime.

2020testuser commented 3 years ago

@ibmmqmet - Thanks! I meant when I use go run command, I get the above error. Using Dockerfile, I'm able to successfully do the build. But, when I run docker run command, I get the below error.

MQCONNX: MQCC = MQCC_FAILED [2] MQRC = MQRC_NOT_AUTHORIZED [2035]

Could you please let me know whether I need to change any permissions for /mq directories for the user that I'm using in the amqsput.go file?

Any suggestions to resolve the issue would be very useful. Thanks in advance!!

ibmmqmet commented 3 years ago

That's nothing to do with file permissions. The userid associated with the connection request is either not being authenticated (wrong userid/password) or is not authorised for some reason. The error logs in the qmgr will have more details. See amqsconn.go for how you can send userid/pw.

2020testuser commented 3 years ago

@ibmmqmet - Thanks for pointing to the amqsconn.go file. I tried disabling the authentication as below in the code and on the server side, the admin disabled (temporarily) disabled the validation as well. However, I'm still getting the same error.

Could you please let me know whether to disable the authentication, anything else need to be done? Any help would be very useful for me to move forward. In the Dockerfile, do I need to set the USER (as 1001 or non-root user)? I also included MQSNOAUT = yes in the Dockerfile. Still, no luck.

Thanks in advance! Modified Code: `

    csp := ibmmq.NewMQCSP()
    csp.AuthenticationType = ibmmq.MQCSP_AUTH_NONE //ibmmq.MQCSP_AUTH_USER_ID_AND_PWD

    // Make the CNO refer to the CSP structure so it gets used during the connection
    cno.SecurityParms = csp
}

// And now we can try to connect. Wait a short time before disconnecting.
qMgr, err = ibmmq.Connx(qMgrName, cno)`

Modified Dockerfile: Added the below lines in the docker file as was getting Permission denied error on /IBM and /mqm directories. 50000 is the port MQClient.

RUN chmod -R 777 $GOPATH_ARG/bin/amqsconn RUN chmod -R 777 $GOPATH_ARG/src/amqsconn.go RUN mkdir -p /IBM \ && chmod -R 777 /IBM RUN mkdir -p /.mqm \ && chmod -R 777 /.mqm ENV MQSNOAUT=yes EXPOSE 50000 8080

ibmmqmet commented 3 years ago

As I said before, the qmgr error logs will tell you what is wrong with your security config. Otherwise it's just guessing.

2020testuser commented 3 years ago

Thanks! I don't see container when I run the below command as the docker run failed with the message. If I have the container, I can check the logs. Could you please let me know whether there is any other way to check the logs? Sorry. I'm new to MQC and trying to get this working. Appreciate your help.

docker run mqcdocker:v1 Connection to MQMGR failed. MQCONNX: MQCC = MQCC_FAILED [2] MQRC = MQRC_NOT_AUTHORIZED [2035]

docker container ls CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

Also, this is what the admin sees on the server side. ` Process(91789.2201) User(mqm) Program(test) Host(myhostname) Installation(Installation1) VRMF(9.1.0.3) QMgr() Time(2021-05-17T1xxxxx) ArithInsert1(2) ArithInsert2(2035) CommentInsert1(unknown) CommentInsert2(hrmsmq21) CommentInsert3(UNKNOWN)

AMQ9557E: Queue Manager User ID initialization failed for 'unknown'.

EXPLANATION: The call to initialize the User ID 'unknown' failed with CompCode 2 and Reason

  1. If an MQCSP block was used, the User ID in the MQCSP block was 'hrmsmq1'. If a userID flow was used, the User ID in the UID header was 'UNKNOWN' and any CHLAUTH rules applied prior to user adoption were evaluated case-sensitively against this value. ACTION: Correct the error and try again.

`

2020testuser commented 3 years ago

@ibmmqmet - Do you have any info. to troubleshoot the issue ? If so, could you please send the details? Thanks!

ibmmqmet commented 3 years ago

Likely reasons are 1) You may have not set a valid userid/password combination in the CSP structure - based on how the qmgr is configured to authenticate ids (eg userids knowin in the container) 2) And/or perhaps the ADOPTCTX attribute on the queue manager's active AUTHINFO object is set to NO.

2020testuser commented 3 years ago

@ibmmqmet - Thanks! Yes, the userid didn't have the right permissions on the Dockerfile. Finally, worked after setting the right permissions.