From 9a32c3856a2ddeafca2208b77c66247835a04de8 Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Mon, 29 Dec 2025 16:15:53 +0800
Subject: [PATCH] fix(okxNewPrice): 修复WebSocket连接配置错误
---
src/main/java/com/xcong/excoin/modules/okxNewPrice/OkxQuantWebSocketClient.java | 36 ++++++++++++++++++++++++------------
1 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/src/main/java/com/xcong/excoin/modules/okxNewPrice/OkxQuantWebSocketClient.java b/src/main/java/com/xcong/excoin/modules/okxNewPrice/OkxQuantWebSocketClient.java
index cdb9117..1fb20c7 100644
--- a/src/main/java/com/xcong/excoin/modules/okxNewPrice/OkxQuantWebSocketClient.java
+++ b/src/main/java/com/xcong/excoin/modules/okxNewPrice/OkxQuantWebSocketClient.java
@@ -4,19 +4,18 @@
import com.alibaba.fastjson.JSONObject;
import com.xcong.excoin.modules.okxNewPrice.celue.CaoZuoService;
import com.xcong.excoin.modules.okxNewPrice.okxWs.*;
+import com.xcong.excoin.modules.okxNewPrice.okxWs.enums.CoinEnums;
import com.xcong.excoin.modules.okxNewPrice.okxWs.enums.ExchangeInfoEnum;
+import com.xcong.excoin.modules.okxNewPrice.okxWs.param.TradeRequestParam;
import com.xcong.excoin.modules.okxNewPrice.utils.SSLConfig;
-import com.xcong.excoin.modules.okxNewPrice.wangge.WangGeService;
import com.xcong.excoin.utils.RedisUtils;
import lombok.extern.slf4j.Slf4j;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.handshake.ServerHandshake;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
+import java.math.BigDecimal;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.concurrent.*;
@@ -31,10 +30,9 @@
*/
@Slf4j
public class OkxQuantWebSocketClient {
- private final WangGeService wangGeService;
- private final CaoZuoService caoZuoService;
private final RedisUtils redisUtils;
private final ExchangeInfoEnum account;
+ private final CaoZuoService caoZuoService;
private WebSocketClient webSocketClient;
private ScheduledExecutorService heartbeatExecutor;
@@ -45,10 +43,26 @@
private final AtomicBoolean isConnected = new AtomicBoolean(false);
private final AtomicBoolean isConnecting = new AtomicBoolean(false);
- public OkxQuantWebSocketClient(ExchangeInfoEnum account, WangGeService wangGeService,
- CaoZuoService caoZuoService, RedisUtils redisUtils) {
+ /**
+ * 获取WebSocketClient实例
+ * @return WebSocketClient实例
+ */
+ public WebSocketClient getWebSocketClient() {
+ return webSocketClient;
+ }
+
+ /**
+ * 获取账号名称
+ * @return 账号名称
+ */
+ public String getAccountName() {
+ return account.name();
+ }
+
+ public OkxQuantWebSocketClient(ExchangeInfoEnum account,
+ CaoZuoService caoZuoService,
+ RedisUtils redisUtils) {
this.account = account;
- this.wangGeService = wangGeService;
this.caoZuoService = caoZuoService;
this.redisUtils = redisUtils;
}
@@ -372,8 +386,6 @@
OrderInfoWs.handleEvent(response, redisUtils, account.name());
}else if (AccountWs.ACCOUNTWS_CHANNEL.equals(channel)) {
AccountWs.handleEvent(response, account.name());
- String side = caoZuoService.caoZuo(account.name());
- TradeOrderWs.orderEvent(webSocketClient, side, account.name());
} else if (PositionsWs.POSITIONSWS_CHANNEL.equals(channel)) {
PositionsWs.handleEvent(response, account.name());
} else if (BalanceAndPositionWs.CHANNEL_NAME.equals(channel)) {
@@ -473,7 +485,7 @@
}
int attempt = 0;
- int maxAttempts = 5;
+ int maxAttempts = 3;
long delayMs = 1000;
while (attempt < maxAttempts && !isConnected.get()) {
--
Gitblit v1.9.1