fix: 排查TCP SERVER 发布RTCM消息的断联问题

This commit is contained in:
yarnom 2025-10-29 11:35:40 +08:00
parent 499cbd663b
commit fb095ad52c

View File

@ -288,15 +288,31 @@ public class RtkClusterService implements ApplicationRunner {
private void dequeueLoop() { private void dequeueLoop() {
byte[] pending = null; byte[] pending = null;
boolean lastWaitLogged = false;
while (true) { while (true) {
try { try {
Socket out = outConn;
Socket sink = inConn; Socket sink = inConn;
if (sink == null || sink.isClosed() || sink == outConn) { if (out == null) {
// wait for a valid IN sink before consuming queue // wait until OUT连接已就绪rtkrcv 已输出首包/特征头
ensureInCandidate(); if (!lastWaitLogged) {
Thread.sleep(20); LOGGER.info("Endpoint {} waiting for OUT to be ready before sending RTCM", port);
lastWaitLogged = true;
}
Thread.sleep(50);
continue; continue;
} }
if (sink == null || sink.isClosed() || sink == out) {
// 等待有效的 IN 连接且不能与 OUT 相同
if (!lastWaitLogged) {
LOGGER.info("Endpoint {} waiting for IN to be ready before sending RTCM", port);
lastWaitLogged = true;
}
ensureInCandidate();
Thread.sleep(50);
continue;
}
lastWaitLogged = false;
if (pending == null) { if (pending == null) {
pending = rtcmQueue.pollFirst(100, TimeUnit.MILLISECONDS); pending = rtcmQueue.pollFirst(100, TimeUnit.MILLISECONDS);
if (pending == null) continue; if (pending == null) continue;