Connect_With_Options don't raise exception but doesn't connect

Asked by Exter

Hello,

I'm trying to connect to an MQ Channel with the command:

qmgr.connect_with_options(self.QMgrName, cd=cd, opts=connect_options)

When using an Administrator user it works fine on V7.0, but when I'm using a user which is not administrator and has the correct privileges on the QueueManager and the channel it doesn't work!

I'm not getting any exception but when i check the attribute qmgr.is_connected, i get a False, so anything is working.

The problem is now that I have a version 7.1, when using an administrator user I get an error 2035, so i want to connect with a non-administrator user (IBM says so). On V7.0 I get the same thing, no exception, and is_connected is false when using a non-adminsitrator user!

Is there anything i'm doing wrong?

Thanks!

Question information

Language:
English Edit question
Status:
Answered
For:
PyMQI Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Dariusz Suchojad (dsuch) said :
#1

Hi Exter,

on the face of it, it seems you're doing everything OK so I need the smallest possible program which exhibits the behaviour you're describing. I won't be able to help you at all without seeing the code first.

Cheers!

Revision history for this message
Exter (extermillenium) said :
#2

Hello!

Thanks for the quick answer.

The code basically is this one, it doesnt get to the exceptions when using a non-administrator user, but self._qmgr.is_connected is false!

The code gets where self.Status = "Not connected."!

If I use an administrator user in version 7.1, it gets into the exception with code 2035! If I use an administrator with version 7.0, self._qmgr.is_connected is true!

Can it be something about MQ configuration?

------------------------------------
      try:
            cd = pymqi.cd()
            cd.ChannelName = self._srv_conn_channel_name
            cd.ConnectionName = listener
            cd.ChannelType = CMQC.MQCHT_CLNTCONN
            cd.TransportType = CMQC.MQXPT_TCP
            if self._mcauserid is not None:
                    cd.MCAUserIdentifier = self._mcauserid

            cd.set()
            self._qmgr.connect_with_options(self.QMgrName, cd=cd, opts=connect_options)

      except pymqi.MQMIError, mqi_error:
            traceback_str = traceback.format_exc()
            if mqi_error.reason == 2391:
                # MQMIError: MQI Error. Comp: 1, Reason 2391: WARNING:
                # MQRC_SSL_ALREADY_INITIALIZED
                # This is a warning but we treat it as an error because it
                # shouldn't happen
                msg = "The SSL is already initialized.\n" +\
                      " %s" % mqi_error.errorAsString()
            ....
            ....
        #a lot of exceptions treated
            ....
      except Exception:
            traceback_str = traceback.format_exc()
            msg = "Queue Manager could not be connected.\n" +\
                  "Details: %s" % traceback_str
            self.Log(CLogger.ERROR, msg)
            self.IsConnected = False
            self.Status = "Not Connected. Reason: %s" % msg
            return False

        self.IsConnected = self._qmgr.is_connected
        if self.IsConnected:
            self.Status = "Connected."
            return True
        else:
            self.Status = "Not connected."
            return False

Revision history for this message
Dariusz Suchojad (dsuch) said :
#3

> The code basically is this one, it doesnt get to the exceptions when using a non-administrator user,
> but self._qmgr.is_connected is false!
>
> The code gets where self.Status = "Not connected."!
>
> If I use an administrator user in version 7.1, it gets into the exception with code 2035!
> If I use an administrator with version 7.0, self._qmgr.is_connected is true!
>
> Can it be something about MQ configuration?

Hm hm hm.. so I think the culprit is indeed how MQ is configured although that's not the only thing happening here.

I'm leaning towards the configuration because of the fact that you /are/ able to connect when certain conditions are met, that is, when you're an administrator. The thing that when using the other MQ version you still can't connect as an admin would mean that the other queue manager isn't configured exactly as the one which lets you in. In any case, MQRC 2035 means the connection as such works fine and it's only a matter of setting permissions for accessing MQ objects.

A thing that may be misleading is in the way how .is_connected works. What it does basically is to ping a queue manager and any exception in that call is turned into returning False whereas no exception means True (i.e. the connection is OK). You can perhaps have a look at this method and modify to your needs, that is, make it raise an exception instead of returning a boolean False.

Other than that, your code looks just fine. The only superfluous thing is the call to 'cd.set()' - this is a no-op and can be done away with.

Can you help with this problem?

Provide an answer of your own, or ask Exter for more information if necessary.

To post a message you must log in.