fix: 排查TCP SERVER 发布RTCM消息的断联问题
This commit is contained in:
parent
fb095ad52c
commit
3522e16070
@ -256,6 +256,21 @@ public class RtkClusterService implements ApplicationRunner {
|
||||
}
|
||||
// IN should not be the same socket as OUT
|
||||
if (inConn == s) inConn = null;
|
||||
// Try minimal handshake if this looks like an HTTP/NTRIP GET from RTKLIB,
|
||||
// to keep the connection open when rtkrcv mistakenly uses ntripcli.
|
||||
try {
|
||||
String head = new String(buf, 0, Math.min(read, 256), StandardCharsets.US_ASCII);
|
||||
if (head.startsWith("GET ") || head.contains("RTKLIB/")) {
|
||||
OutputStream os = s.getOutputStream();
|
||||
String resp = head.contains("HTTP")
|
||||
? "HTTP/1.1 200 OK\r\nConnection: keep-alive\r\n\r\n"
|
||||
: "ICY 200 OK\r\n\r\n";
|
||||
os.write(resp.getBytes(StandardCharsets.US_ASCII));
|
||||
os.flush();
|
||||
LOGGER.info("[OUT:{}] handshake responded: {}", port, resp.trim());
|
||||
}
|
||||
} catch (Exception ignore) {}
|
||||
LOGGER.info("Endpoint {} OUT established", port);
|
||||
}
|
||||
String preview = new String(buf, 0, read, StandardCharsets.US_ASCII).replaceAll("\n", "\\n");
|
||||
LOGGER.info("[OUT:{}] {}", port, preview);
|
||||
@ -264,7 +279,10 @@ public class RtkClusterService implements ApplicationRunner {
|
||||
LOGGER.debug("Connection reader closed on {}: {}", port, e.getMessage());
|
||||
} finally {
|
||||
liveConns.remove(s);
|
||||
if (outConn == s) outConn = null;
|
||||
if (outConn == s) {
|
||||
outConn = null;
|
||||
LOGGER.info("Endpoint {} OUT disconnected", port);
|
||||
}
|
||||
if (inConn == s) inConn = null;
|
||||
closeQuietly(s);
|
||||
ensureInCandidate();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user