0
votes

I have two console applications, A and B. The application A was created for test purposes and works as expected. The application B does not work although it is basically a copy-paste of A's code:

System.Console.Write("User Name: ");
string username = System.Console.ReadLine();
System.Console.Write("Password: ");
string password = ConsoleReadPassword();
System.Console.WriteLine();

//user and password required because I am also a privileged user 
//(member of mqm group)
MQEnvironment.UserId = username;
MQEnvironment.Password = password;

//for application B this line throws exception with code 2538
var queueManager = new MQQueueManager("TEST.QUEUE.MANAGER", "CLIENT.CONN.CHANNEL", "localhost(1414)");

Error code 2538 means "Host not available" which is weird because application A has no problems connecting to the same host.

This is how the MQ Server looks in MQ Explorer:

Queue managers: queue managers

Queues: queues

Listeners: listeners

Channels: channels Two server channels

Channel auth records: channel authentication records Default channel authentication record which prevents MQ admins from connecting to queue managers. It was slightly modified (added ~ prefix) so now it does not block anyone.

The MQ Server and applications are running on the same machine so imho network problems are excluded.

The queue manager error log does not report any errors but the general error log looks like this:

08/02/2016 15:15:23 - Process(13720.10) User([username]) Program(B.EXE) AMQ9202: Remote host 'localhost(1414)' not available, retry later.

EXPLANATION: The attempt to allocate a conversation using TCP/IP to host 'localhost(1414)' for channel (Exception) was not successful. However the error may be a transitory one and it may be possible to successfully allocate a TCP/IP conversation later.

For both application I use the same version of amqmdnet.dll: 8.0.0.4

Both programs A and B have the same target framework: 4.5

While testing I didn't tried to run the both applications in the same time and I checked in MQ Explorer if the channel is free (Inactive).

I also tried to change the name of resulting assemblies but with no effect.

Does anyone know what could cause application B to be unable to connect?

2
You may wish to tag this with [websphere-mq] (rather than the separate [websphere] and [mq] tags) so that the right people see it. The [websphere] tag description says it is used for Websphere Application Server.Azquelt
I've made some assumptions about what machines are involved in my answer, but it would be helpful if you could update your question with the details of which machines ard in use.Morag Hughson

2 Answers

0
votes

When using the hostname localhost networking is still involved, it just all happens inside the one machine. If application A is running in the same machine as your queue manager then having application A connect using the connection name localhost(1414) will certainly work but it is not necessary to make the connection like this (i.e. using TCP/IP) you could instead make a local bindings connection.

On the other hand, if you are using TCP/IP because application B is running on a different machine to where the queue manager is running, then using localhost(1414) will not work because localhost on one machine does not connect to localhost on another machine. You should change what is specified in the application's connection name from localhost(1414) to use the IP address (or hostname) of the queue manager's machine (followed as before with the port number).

0
votes

Although I was unable to find the cause of the problem the solution was to simply

delete and re-create the project.

This is what I tried before and what led me to this action:

  • In B I removed and then added back the reference to amqmdnet.dll - not working
  • I created yet another project (let's call it C): console application, same code - working
  • I renamed* the C project with the same name as B - still working

    *The name of the non-working project contained a dot so I thought that this could cause the problem - it was not the case.