第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

asyncio 掛在 SSL 握手上

asyncio 掛在 SSL 握手上

慕運(yùn)維8079593 2023-05-09 15:23:43
我目前正在將一些遺留代碼遷移到 asyncio 并遇到有關(guān) SSL 握手的問(wèn)題。我正在創(chuàng)建一個(gè) SSL 服務(wù)器:import osimport socketimport asynciofrom myexample import Connectionstorage_path = '.' # Path where certificates are stored (self-signed)ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)ssl_context.load_verify_locations(    cafile = os.path.join(storage_path, 'root.cert'))ssl_context.load_cert_chain(    certfile = os.path.join(storage_path, 'test-server.cert'),     keyfile  = os.path.join(storage_path, 'test-server.key'))ssl_context.verify_mode = ssl.VerifyMode.CERT_REQUIREDloop = asyncio.new_event_loop()loop.set_debug(True)async def create_server_wrapped():    server = await self.loop.create_server(        Connection, # Connection class; Doesn't matter which one, issue also happens with examples from Python wiki        '127.0.0.1',         20000,        ssl = ssl_context,        reuse_port      = True,        reuse_address   = False,        backlog         = 1000    )    await server.serve_forever()loop.run_until_complete(create_server_wrapped())loop.run_forever()我通過(guò)普通插座連接:import osimport sslimport socketstorage_path = '.' # Path where certificates are stored (self-signed)cert_file   = os.path.join(storage_path, 'client.cert')pkey_file   = os.path.join(storage_path, 'client.key')context = ssl.create_default_context(    purpose = ssl.Purpose.SERVER_AUTH,     cafile = os.path.join(storage_path, 'root.cert'))context.load_cert_chain(cert_file, pkey_file)context.check_hostname = False # Connecting by IPplain_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)plain_socket.settimeout(5)if not plain_socket.getsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE):    plain_socket.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)    plain_socket.setsockopt(socket.SOL_TCP, socket.TCP_KEEPINTVL, 2)    sock = context.wrap_socket(plain_socket, server_side = False)sock.connect(('127.0.0.1', 20700))嘗試連接時(shí),大多數(shù)時(shí)候我會(huì)得到一個(gè)socket.error: _ssl.c:1039: The handshake operation timed out
查看完整描述

1 回答

?
開滿天機(jī)

TA貢獻(xiàn)1786條經(jīng)驗(yàn) 獲得超13個(gè)贊

問(wèn)題是通過(guò)啟用reuse_port. 雖然這是想要的行為(使用同一端口運(yùn)行多個(gè)進(jìn)程以實(shí)現(xiàn)負(fù)載平衡),但它會(huì)以某種方式導(dǎo)致問(wèn)題。

禁用它并利用正常的負(fù)載平衡解決了我遇到的問(wèn)題。


查看完整回答
反對(duì) 回復(fù) 2023-05-09
  • 1 回答
  • 0 關(guān)注
  • 153 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)