mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-22 07:03:53 +08:00
Merge pull request #1890 from xinnan-tech/manager-api-mcp
修复mcp工具太多会获取不到内容的bug
This commit is contained in:
+1
@@ -65,6 +65,7 @@ public class AgentMcpAccessPointServiceImpl implements AgentMcpAccessPointServic
|
||||
try (WebSocketClientManager client = WebSocketClientManager.build(
|
||||
new WebSocketClientManager.Builder()
|
||||
.uri(wsUrl)
|
||||
.bufferSize(1024 * 1024)
|
||||
.connectTimeout(8, TimeUnit.SECONDS)
|
||||
.maxSessionDuration(10, TimeUnit.SECONDS))) {
|
||||
|
||||
|
||||
+12
-2
@@ -86,10 +86,14 @@ public class WebSocketClientManager implements Closeable {
|
||||
if (sess == null || !sess.isOpen()) {
|
||||
throw new IOException("握手失败或会话未打开");
|
||||
}
|
||||
// 设置缓冲区
|
||||
sess.setTextMessageSizeLimit(b.bufferSize);
|
||||
sess.setBinaryMessageSizeLimit(b.bufferSize);
|
||||
ws.session = sess;
|
||||
return ws;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 发送 Text
|
||||
*/
|
||||
@@ -308,10 +312,11 @@ public class WebSocketClientManager implements Closeable {
|
||||
if (stopWatch.isRunning()) {
|
||||
stopWatch.stop();
|
||||
}
|
||||
log.info("ws连接关闭, 目标URI: {}, 关闭时间: {}, 连接总时长: {}s",
|
||||
log.info("ws连接关闭, 目标URI: {}, 关闭时间: {}, 连接总时长: {}s,断开原因:{}",
|
||||
targetUri, DateUtils.getDateTimeNow(DateUtils.DATE_TIME_MILLIS_PATTERN),
|
||||
DateUtils.millsToSecond(stopWatch.getTotalTimeMillis()));
|
||||
DateUtils.millsToSecond(stopWatch.getTotalTimeMillis()),status);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
@@ -321,6 +326,7 @@ public class WebSocketClientManager implements Closeable {
|
||||
private long maxSessionDuration = 5; // 最大连线时间,默认5秒
|
||||
private TimeUnit maxSessionDurationUnit = TimeUnit.SECONDS; // 最大连线时间单位
|
||||
private int queueCapacity = 100; // 消息队列容量
|
||||
private int bufferSize = 8 * 1024; //默认 8kb
|
||||
private WebSocketHttpHeaders headers; // 请求头
|
||||
|
||||
/**
|
||||
@@ -352,6 +358,10 @@ public class WebSocketClientManager implements Closeable {
|
||||
this.queueCapacity = c;
|
||||
return this;
|
||||
}
|
||||
public Builder bufferSize(int c) {
|
||||
this.bufferSize = c;
|
||||
return this;
|
||||
}
|
||||
|
||||
public WebSocketClientManager build()
|
||||
throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
||||
|
||||
Reference in New Issue
Block a user