簡體   English   中英

Python stomp 升級到 8.0.1 導致 SSL Library not found 錯誤

[英]Python stomp upgrade to 8.0.1 causes SSL Library not found error

我已將 python stomp 客戶端從 7.0.0 升級到 8.0.1,現在嘗試連接到隊列時出現錯誤消息。

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

在 package 代碼的這一部分中似乎拋出了錯誤: https://github.com/jasonrbriggs/stomp.py/blob/dev/stomp/transport.py#L843

可能由更新引起: https://github.com/jasonrbriggs/stomp.py/commit/624d904d0a595c9f2b0b67c082579c7c1ca2ab5b

問題

  • 我們需要對客戶端連接代碼進行哪些更新才能使其再次正常工作?
  • 我們是否需要向 set_ssl() 傳遞一個選項?

代碼

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)

我們必須在我們的環境中添加密碼學 package 才能使其正常工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM