import json
from ws4py.client.threadedclient import WebSocketClient
class WS_Client(WebSocketClient):
def opened(self):
req = '{req}'
self.send(req)
def closed(self, code, reason=None):
print("Closed down:", code, reason)
def received_message(self, resp):
resp = json.loads(str(resp))
print(resp)
if __name__ == '__main__':
ws = None
try:
url = 'wss://{url}'
ws = WS_Client(url=url, )
ws.connect()
ws.run_forever()
except KeyboardInterrupt:
ws.close()
//Python升级到3.11后证书报错....
问题起因
链接WebSocket报错:
obj.do_handshake()
ssl.SSLError: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:992)
尝试从Python3.8升级到3.11升级后继续报错:
obj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:992)
解决了两天...终于TMD解决了, 原来如此...简答
应用程序 → Python 3.11 → 双击运行 Install Certificates.command → 重启Pycharm → 解决
也可以先尝试下安装 anvil-uplink
pip3 install anvil-uplink
unable to get local issuer certificate (_ssl.c:992)‘)]-优快云博客 感谢博主