collumbo
collumbo

Reputation: 527

Connecting to Websphere MQ in C# works, but fails in C++ with code 2058 (MQRC_Q_MGR_NAME_ERROR)

I need to write a piece of code to put a message into MQ using C++. When I test it on localhost, using the default port (1414) it works. However, in the actual environment, which uses specific channel definition and different port (1420), it fails with reason code 2058 / MQRC_Q_MGR_NAME_ERROR. There is no problem connecting to the remote MQ using Websphere MQ Explorer. There is also no problem connecting to the same remote server in a C# app to prove connectivity. Any ideas what could be causing it?

Some sample code extract: C++ which fails when .connect() is called...

ImqChannel * pChannel_ = 0;  // Channel definition which is at class level
ImqQueueManager queueManager_;   // Queue Manager, also declared at class level


// extract from the MQHelper::Connect() method... 
int MQClient::Connect() {
   pChannel_ = new ImqChannel;
   pChannel_->setChannelName("CLCHL.QM");
   pChannel_->setTransportType(MQXPT_TCP);
   pChannel_->setConnectionName("10.2.3.4(1420)");
   // Should we set this???! pChannel_->setModeName("to what?");

   queueManager_.setName("QM");
   queueManager_.setChannelReference(pChannel_);

   if (!queueManager_.connect()) {
      // ERROR IS HERE: _lastCompletionCode is 2, _lastReasonCode is 2058
      _lastCompletionCode = queueManager_.completionCode();
      _lastReasonCode = queueManager_.reasonCode();
      return (int)_lastReasonCode;
   }
    // If we get here, we're all good:
   return 0;
}

In C#, there is no such problem: the following code will connect fine..

queueManager = new MQQueueManager("QM", "CLCHL.QM", "10.2.3.4(1420)");

Other info:

Any ideas?

Upvotes: 1

Views: 799

Answers (1)

Roger
Roger

Reputation: 7476

ImqChannel * pChannel_ = 0;  // Channel definition which is at class level
ImqQueueManager queueManager_;   // Queue Manager, also declared at class level

What's with the extra underscore in the variable names?

queueManager_.setName("QM");

Is that the ACTUAL queue manager name of the remote queue manager? It needs to be the correct value. Note: MQ is case sensitive. ie. "QM" is not the same as "qm".

Each queue manager's listener listens on a different port.

pChannel_->setConnectionName("10.2.3.4(1420)");

Are you sure queue manager "QM" is actually listening on port 1420 and not 1414 or 1419 or 1421 etc..

Upvotes: 1

Related Questions