From 99e403f89e9ee1846ac80251372227103b3bb6d6 Mon Sep 17 00:00:00 2001 From: ghlds <1033554981@qq.com> Date: Thu, 19 Jun 2025 19:52:42 +0800 Subject: [PATCH] =?UTF-8?q?=E9=83=A8=E5=88=86=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manager-api/src/main/resources/application.yml | 4 ++++ main/xiaozhi-server/config.yaml | 2 +- main/xiaozhi-server/core/websocket_server.py | 14 ++++++++++---- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/main/manager-api/src/main/resources/application.yml b/main/manager-api/src/main/resources/application.yml index 7594c2208..fb73f8fba 100644 --- a/main/manager-api/src/main/resources/application.yml +++ b/main/manager-api/src/main/resources/application.yml @@ -1,5 +1,9 @@ # Tomcat server: + # ssl: + # key-store: classpath:ssl.pfx + # key-store-password: zy123456 + # key-store-type: PKCS12 tomcat: uri-encoding: UTF-8 threads: diff --git a/main/xiaozhi-server/config.yaml b/main/xiaozhi-server/config.yaml index 6dc0b25d4..782b7cdb1 100644 --- a/main/xiaozhi-server/config.yaml +++ b/main/xiaozhi-server/config.yaml @@ -17,7 +17,7 @@ server: # 当你使用docker部署或使用公网部署(使用ssl、域名)时,不一定准确 # 所以如果你使用docker部署时,将websocket设置成局域网地址 # 如果你使用公网部署时,将vwebsocket设置成公网地址 - websocket: ws://你的ip或者域名:端口号/xiaozhi/v1/ + websocket: ws://192.168.31.182:8000/xiaozhi/v1/ # 视觉分析接口地址 # 向设备发送的视觉分析的接口地址 # 如果按下面默认的写法,系统会自动生成视觉识别地址,并输出在启动日志里,这个地址你可以直接用浏览器访问确认一下 diff --git a/main/xiaozhi-server/core/websocket_server.py b/main/xiaozhi-server/core/websocket_server.py index 2b89e065d..1aa7898d1 100644 --- a/main/xiaozhi-server/core/websocket_server.py +++ b/main/xiaozhi-server/core/websocket_server.py @@ -47,10 +47,16 @@ class WebSocketServer: keyfile=ssl_config["keyfile"] ) print(f"run with SSL") - async with websockets.serve( - self._handle_connection, host, port, process_request=self._http_response, ssl=ssl_context - ): - await asyncio.Future() + async with websockets.serve( + self._handle_connection, host, port, process_request=self._http_response, ssl=ssl_context + ): + await asyncio.Future() + else: + print(f"run without SSL") + async with websockets.serve( + self._handle_connection, host, port, process_request=self._http_response + ): + await asyncio.Future() async def _handle_connection(self, websocket): """处理新连接,每次创建独立的ConnectionHandler"""