Python stomp upgrade to 8.0.1 causes SSL Library not found error

Viewed 64

I've upgraded python stomp client from 7.0.0 to 8.0.1 and now an error message appears when attempting to connect to the queue.

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/mpsmqutils/mqlistener.py", line 64, in connect_and_subscribe
    conn.set_ssl([(_host, _port)])
  File "/usr/local/lib/python3.8/site-packages/stomp/connect.py", line 68, in set_ssl
    self.transport.set_ssl(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/stomp/transport.py", line 859, in set_ssl
    raise Exception("SSL connection requested, but SSL library not found")
Exception: SSL connection requested, but SSL library not found

The error appears to be thrown in this part of the package code: https://github.com/jasonrbriggs/stomp.py/blob/dev/stomp/transport.py#L843

Probably caused by update: https://github.com/jasonrbriggs/stomp.py/commit/624d904d0a595c9f2b0b67c082579c7c1ca2ab5b

Questions

  • What updates do we need to make to our client connection code to get this working again?
  • Do we need to pass in an option to set_ssl()?

Code

def connect_and_subscribe(conn, queue=_queue, sub_id=_sub_id):
    print(_hostname_prefix + "************************ MQUTILS MQLISTENER - CONNECT_AND_SUBSCRIBE *******************************")
    global _reconnect_attempts
    _reconnect_attempts = _reconnect_attempts + 1
    if _reconnect_attempts <= _max_attempts:
        # TODO: Retry timer with exponential backoff
        time.sleep(1)
        try:
            if not os.getenv('MQ_DISABLE_SSL'):
                if _failback_host and _failback_port:
                    conn.set_ssl([(_host, _port),(_failback_host, _failback_port)])
                else:
                    conn.set_ssl([(_host, _port)])
            if not conn.is_connected():
                conn.connect(_user, _password, headers={'client-id': _client_id}, wait=True)
                print(f'{_hostname_prefix}connect_and_subscribe connecting {queue} to with connection id {sub_id} reconnect attempts: {_reconnect_attempts}', flush=True)
            else:
                print(f'{_hostname_prefix}connect_and_subscibe already connected {queue} to with connection id {sub_id} reconnect attempts {_reconnect_attempts}', flush=True)
        except Exception as e:
            print(_hostname_prefix + 'Exception on disconnect. reconnecting...')
            print(_hostname_prefix + traceback.format_exc())
            connect_and_subscribe(conn)
        else:
            conn.subscribe(destination=queue, id=sub_id, ack='client-individual')
            _reconnect_attempts = 0
    else:
        print('{}Maximum reconnect attempts reached for this connection. reconnect attempts: {}'.format(_hostname_prefix, _reconnect_attempts), flush=True)
1 Answers

We had to add the cryptography package in our environment to get this working correctly.

Related