From 304f66653474ff7684bb3ddbed38ff7f908195ee Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Tue, 02 Jun 2026 13:47:08 +0800
Subject: [PATCH] fix(okxNewPrice): 解决WebSocket连接超时问题
---
src/main/java/com/xcong/excoin/modules/okxNewPrice/OkxGridWsClient.java | 17 +++++++++++------
1 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/src/main/java/com/xcong/excoin/modules/okxNewPrice/OkxGridWsClient.java b/src/main/java/com/xcong/excoin/modules/okxNewPrice/OkxGridWsClient.java
index da664ba..46b5ac8 100644
--- a/src/main/java/com/xcong/excoin/modules/okxNewPrice/OkxGridWsClient.java
+++ b/src/main/java/com/xcong/excoin/modules/okxNewPrice/OkxGridWsClient.java
@@ -38,10 +38,10 @@
private static final int HEARTBEAT_TIMEOUT = 10;
- /** 模拟盘公共 WS 地址 */
- private static final String WS_PUBLIC_URL_SIM = "wss://wspap.okx.com:8443/ws/v5/public";
- /** 实盘公共 WS 地址 */
- private static final String WS_PUBLIC_URL_PROD = "wss://ws.okx.com:8443/ws/v5/public";
+ /** 模拟盘业务 WS 地址(K线等行情数据) */
+ private static final String WS_BUSINESS_URL_SIM = "wss://wspap.okx.com:8443/ws/v5/business";
+ /** 实盘业务 WS 地址(K线等行情数据) */
+ private static final String WS_BUSINESS_URL_PROD = "wss://ws.okx.com:8443/ws/v5/business";
/** 模拟盘私有 WS 地址 */
private static final String WS_PRIVATE_URL_SIM = "wss://wspap.okx.com:8443/ws/v5/private";
/** 实盘私有 WS 地址 */
@@ -119,9 +119,9 @@
System.setProperty("https.protocols", "TLSv1.2,TLSv1.3");
String wsUrl;
if (account.isAccountType()) {
- wsUrl = isPublic ? WS_PUBLIC_URL_PROD : WS_PRIVATE_URL_PROD;
+ wsUrl = isPublic ? WS_BUSINESS_URL_PROD : WS_PRIVATE_URL_PROD;
} else {
- wsUrl = isPublic ? WS_PUBLIC_URL_SIM : WS_PRIVATE_URL_SIM;
+ wsUrl = isPublic ? WS_BUSINESS_URL_SIM : WS_PRIVATE_URL_SIM;
}
URI uri = new URI(wsUrl);
@@ -171,6 +171,7 @@
isConnected.set(false);
}
};
+ webSocketClient.setConnectionLostTimeout(0);
webSocketClient.connect();
} catch (URISyntaxException e) {
log.error("[{}] URI格式错误", logPrefix, e);
@@ -212,6 +213,10 @@
private void handleMessage(String message) {
try {
+ if ("pong".equals(message)) {
+ log.debug("[{}] 收到 pong", logPrefix);
+ return;
+ }
JSONObject response = JSON.parseObject(message);
String event = response.getString("event");
String op = response.getString("op");
--
Gitblit v1.9.1