mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-23 23:53:55 +08:00
update:增加ws连接时长,避免ws时间过短到只conn对象销毁丢失无法使用
This commit is contained in:
+4
-3
@@ -89,7 +89,7 @@ public class ServerSideManageController {
|
||||
|
||||
try (WebSocketClientManager client = new WebSocketClientManager.Builder()
|
||||
.connectTimeout(3, TimeUnit.SECONDS)
|
||||
.maxSessionDuration(5, TimeUnit.SECONDS)
|
||||
.maxSessionDuration(120, TimeUnit.SECONDS)
|
||||
.uri(targetWsUri)
|
||||
.headers(headers)
|
||||
.build()) {
|
||||
@@ -104,8 +104,9 @@ public class ServerSideManageController {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
return ServerActionResponseDTO
|
||||
.isSuccess(objectMapper.readValue(jsonText, ServerActionResponseDTO.class));
|
||||
ServerActionResponseDTO response = objectMapper.readValue(jsonText, ServerActionResponseDTO.class);
|
||||
Boolean isSuccess = ServerActionResponseDTO.isSuccess(response);
|
||||
return isSuccess;
|
||||
} catch (JsonProcessingException e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ export default {
|
||||
RequestService.clearRequestTime()
|
||||
callback(res)
|
||||
})
|
||||
.fail((err) => {
|
||||
.networkFail((err) => {
|
||||
console.error('获取ws服务端列表失败:', err)
|
||||
RequestService.reAjaxFun(() => {
|
||||
this.getWsServerList(params, callback)
|
||||
@@ -156,7 +156,7 @@ export default {
|
||||
RequestService.clearRequestTime()
|
||||
callback(res)
|
||||
})
|
||||
.fail((err) => {
|
||||
.networkFail((err) => {
|
||||
RequestService.reAjaxFun(() => {
|
||||
this.sendWsServerAction(data, callback)
|
||||
})
|
||||
|
||||
@@ -82,11 +82,13 @@ class WebSocketServer:
|
||||
if new_config is None:
|
||||
self.logger.bind(tag=TAG).error("获取新配置失败")
|
||||
return False
|
||||
|
||||
self.logger.bind(tag=TAG).info(f"获取新配置成功")
|
||||
# 检查 VAD 和 ASR 类型是否需要更新
|
||||
update_vad = check_vad_update(self.config, new_config)
|
||||
update_asr = check_asr_update(self.config, new_config)
|
||||
|
||||
self.logger.bind(tag=TAG).info(
|
||||
f"检查VAD和ASR类型是否需要更新: {update_vad} {update_asr}"
|
||||
)
|
||||
# 更新配置
|
||||
self.config = new_config
|
||||
# 重新初始化组件
|
||||
@@ -114,7 +116,7 @@ class WebSocketServer:
|
||||
self._intent = modules["intent"]
|
||||
if "memory" in modules:
|
||||
self._memory = modules["memory"]
|
||||
|
||||
self.logger.bind(tag=TAG).info(f"更新配置任务执行完毕")
|
||||
return True
|
||||
except Exception as e:
|
||||
self.logger.bind(tag=TAG).error(f"更新服务器配置失败: {str(e)}")
|
||||
|
||||
Reference in New Issue
Block a user