Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MQRC_CONNECTION_BROKEN [2009] error #164

Open
gowrimech32 opened this issue Jul 4, 2023 · 7 comments
Open

MQRC_CONNECTION_BROKEN [2009] error #164

gowrimech32 opened this issue Jul 4, 2023 · 7 comments

Comments

@gowrimech32
Copy link

I am calling the below node js script from our application.

var mq = require('ibmmq');

 module.exports = {  
   /**
     Check if it is possible to connect to the system using the given connection
    */
     validate: function (input, options, output) {

       var MQC = mq.MQC;
       var qMgr = "XXXXXXX";
 
       var cno = new mq.MQCNO();
       var csp = new mq.MQCSP();
       csp.UserId = "XXXXXX";
       csp.Password = "********";
       cno.SecurityParms = csp;
 
       cno.Options |= MQC.MQCNO_CLIENT_BINDING;
 
       var cd = new mq.MQCD();
       cd.ConnectionName = "XXXXXXXXXX";
       cd.ChannelName = "XXXXXXXX";
       cno.ClientConn = cd;

       mq.Connx(qMgr, cno, function(err,conn) {
         if (err) {
           logger.error(err);
           logger.error('MQ connection validation failed.')
           return output(err, {
             'result' : 'MQ connection validation failed.'
           })
         } else {
           logger.info('MQ connection validation successfully.')
             mq.Disc(conn, function(err) {
               if (err) {
                 logger.error("MQDISC failed");
               } else {
                 logger.info("MQDISC successful");
               }
             });
           return output(null, {
             'result': 'Connection validated successfully'
           })
         }
       });
     }
 }

The application user has access to Queue manager. If i run this method as a standalone script, it works fine. but if i run from application, then getting below error message.

CONNX: MQCC = MQCC_FAILED [2] MQRC = MQRC_CONNECTION_BROKEN [2009];MQCC_FAILED:2009;MQRC_CONNECTION_BROKEN

@chughts
Copy link

chughts commented Jul 4, 2023

RE:

cno.Options |= MQC.MQCNO_CLIENT_BINDING;

Is your application running on the same machine as the queue manager?

@gowrimech32
Copy link
Author

No.... I am trying to connect queue manager which is running in different server.

@chughts
Copy link

chughts commented Jul 4, 2023

That code, as you have already proven, should connect successfully. Which implies that your application is either not using the same code (add a check by logging something in that function that makes it clear that function is being invoked) or it is using it in a different way.

Your function validate takes in 3 arguments, but it is only using one - output.
Is your application expecting validate to do something with input or options ?

@gowrimech32
Copy link
Author

I have already checked by adding loggers. It is invoking the function properly.
I was getting below error. Then i solved it by copying the files from '/opt/mqm/lib64' to my application directory.

ENOENT: no such file or directory, open libmqm_r.so

After adding few more logger, i could see it is failing at below line.

libmqm.MQCONNX.async(mqqMgrName,mqCno.ref(), mqHConn,mqCc,mqRc, function (error,resp)

@chughts
Copy link

chughts commented Jul 5, 2023

That seems to be your platform's equivalent to a LD_LIBRARY_PATH related issue.

From the README.md

For Windows and Linux x64, the npm installation process tries to access
the Redistributable Client packages and unpack them automatically.

...

If you do not want this automatic installation of the MQ runtime, then set the
environment variable MQIJS_NOREDIST to any value before running npm install.
The MQ libraries are then be found at runtime using mechanisms such as
searching LD_LIBRARY_PATH (Linux) or PATH (Windows).

By inference this automatic fetch of the redistributable client isn't performed on other platforms.

@gowrimech32
Copy link
Author

I could see same result after setting LD_LIBRARY_PATH

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/mqm/lib64

@chughts
Copy link

chughts commented Jul 6, 2023

Check that the setting was inherited by the application by logging the value in your code.

eg.

debug_info("LD_LIBRARY_PATH : ", process.env.LD_LIBRARY_PATH);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants