mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-27 17:43:55 +08:00
update:获取nginx转发的ip地址
This commit is contained in:
@@ -184,8 +184,13 @@ class ConnectionHandler:
|
|||||||
await ws.send("端口正常,如需测试连接,请使用test_page.html")
|
await ws.send("端口正常,如需测试连接,请使用test_page.html")
|
||||||
await self.close(ws)
|
await self.close(ws)
|
||||||
return
|
return
|
||||||
# 获取客户端ip地址
|
real_ip = self.headers.get("x-real-ip") or self.headers.get(
|
||||||
self.client_ip = ws.remote_address[0]
|
"x-forwarded-for"
|
||||||
|
)
|
||||||
|
if real_ip:
|
||||||
|
self.client_ip = real_ip.split(",")[0].strip()
|
||||||
|
else:
|
||||||
|
self.client_ip = ws.remote_address[0]
|
||||||
self.logger.bind(tag=TAG).info(
|
self.logger.bind(tag=TAG).info(
|
||||||
f"{self.client_ip} conn - Headers: {self.headers}"
|
f"{self.client_ip} conn - Headers: {self.headers}"
|
||||||
)
|
)
|
||||||
@@ -794,9 +799,7 @@ class ConnectionHandler:
|
|||||||
if len(response_message) > 0:
|
if len(response_message) > 0:
|
||||||
text_buff = "".join(response_message)
|
text_buff = "".join(response_message)
|
||||||
self.tts_MessageText = text_buff
|
self.tts_MessageText = text_buff
|
||||||
self.dialogue.put(
|
self.dialogue.put(Message(role="assistant", content=text_buff))
|
||||||
Message(role="assistant", content=text_buff)
|
|
||||||
)
|
|
||||||
response_message.clear()
|
response_message.clear()
|
||||||
self.logger.bind(tag=TAG).debug(
|
self.logger.bind(tag=TAG).debug(
|
||||||
f"function_name={function_name}, function_id={function_id}, function_arguments={function_arguments}"
|
f"function_name={function_name}, function_id={function_id}, function_arguments={function_arguments}"
|
||||||
@@ -820,9 +823,7 @@ class ConnectionHandler:
|
|||||||
if len(response_message) > 0:
|
if len(response_message) > 0:
|
||||||
text_buff = "".join(response_message)
|
text_buff = "".join(response_message)
|
||||||
self.tts_MessageText = text_buff
|
self.tts_MessageText = text_buff
|
||||||
self.dialogue.put(
|
self.dialogue.put(Message(role="assistant", content=text_buff))
|
||||||
Message(role="assistant", content=text_buff)
|
|
||||||
)
|
|
||||||
if depth == 0:
|
if depth == 0:
|
||||||
self.tts.tts_text_queue.put(
|
self.tts.tts_text_queue.put(
|
||||||
TTSMessageDTO(
|
TTSMessageDTO(
|
||||||
@@ -899,9 +900,7 @@ class ConnectionHandler:
|
|||||||
if self.executor is None:
|
if self.executor is None:
|
||||||
continue
|
continue
|
||||||
# 提交任务到线程池
|
# 提交任务到线程池
|
||||||
self.executor.submit(
|
self.executor.submit(self._process_report, *item)
|
||||||
self._process_report, *item
|
|
||||||
)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.bind(tag=TAG).error(f"聊天记录上报线程异常: {e}")
|
self.logger.bind(tag=TAG).error(f"聊天记录上报线程异常: {e}")
|
||||||
except queue.Empty:
|
except queue.Empty:
|
||||||
|
|||||||
Reference in New Issue
Block a user