GUACAMOLE-377: Set NO_DELAY on guacd socket to avoid unnecessary latency.

This commit is contained in:
Michael Jumper
2025-01-29 09:58:45 -08:00
parent 1a57d41a1b
commit f2958ffb55

View File

@@ -34,6 +34,7 @@ import java.io.OutputStreamWriter;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.net.SocketTimeoutException;
import java.net.StandardSocketOptions;
import org.apache.guacamole.GuacamoleException;
import org.apache.guacamole.GuacamoleServerException;
import org.apache.guacamole.GuacamoleUpstreamTimeoutException;
@@ -102,6 +103,10 @@ public class InetGuacamoleSocket implements GuacamoleSocket {
// Set read timeout
sock.setSoTimeout(SOCKET_TIMEOUT);
// Set TCP_NODELAY to avoid any latency that would otherwise be
// added by the networking stack and Nagle's algorithm
sock.setTcpNoDelay(true);
// On successful connect, retrieve I/O streams
reader = new ReaderGuacamoleReader(new InputStreamReader(sock.getInputStream(), "UTF-8"));
writer = new WriterGuacamoleWriter(new OutputStreamWriter(sock.getOutputStream(), "UTF-8"));