diff --git a/CoreRemoting/Channels/Websocket/WebsocketClientChannel.cs b/CoreRemoting/Channels/Websocket/WebsocketClientChannel.cs
index 3ddc2bd..3f75f12 100644
--- a/CoreRemoting/Channels/Websocket/WebsocketClientChannel.cs
+++ b/CoreRemoting/Channels/Websocket/WebsocketClientChannel.cs
@@ -38,9 +38,7 @@ public void Init(IRemotingClient client)
Convert.ToString(client.Config.ServerPort) +
"/rpc";
- _webSocket = new WebSocket(url);
-
- TryToSetNoDelayFlagOnUnderlyingTcpClient();
+ _webSocket = new WebSocket(url) { NoDelay = true };
_webSocket.SetCookie(new Cookie(
name: "MessageEncryption",
@@ -56,25 +54,7 @@ public void Init(IRemotingClient client)
_webSocket.Log.Output = (timestamp, text) => Console.WriteLine("{0}: {1}", timestamp, text);
_webSocket.Log.Level = LogLevel.Debug;
}
-
- ///
- /// Try to set NoDelay flag on the underlying TcpClient to enhance performance on Linux.
- ///
- private void TryToSetNoDelayFlagOnUnderlyingTcpClient()
- {
- var webSocketType = _webSocket.GetType();
- var tcpClientPrivateField =
- webSocketType.GetField(
- name: "_tcpClient",
- bindingAttr: BindingFlags.NonPublic | BindingFlags.GetField);
-
- if (tcpClientPrivateField != null)
- {
- if (tcpClientPrivateField.GetValue(_webSocket) is TcpClient tcpClient)
- tcpClient.NoDelay = true;
- }
- }
-
+
///
/// Establish a websocket connection with the server.
///
diff --git a/CoreRemoting/Channels/Websocket/WebsocketServerChannel.cs b/CoreRemoting/Channels/Websocket/WebsocketServerChannel.cs
index 2e67d66..b1b42d7 100644
--- a/CoreRemoting/Channels/Websocket/WebsocketServerChannel.cs
+++ b/CoreRemoting/Channels/Websocket/WebsocketServerChannel.cs
@@ -21,33 +21,16 @@ public void Init(IRemotingServer server)
{
_server = server ?? throw new ArgumentNullException(nameof(server));
- _webSocketServer = new WebSocketServer(_server.Config.NetworkPort, secure: false);
-
- TryToSetNoDelayFlagOnUnderlyingTcpListener();
+ _webSocketServer = new WebSocketServer(_server.Config.NetworkPort, secure: false)
+ {
+ NoDelay = true
+ };
_webSocketServer.AddWebSocketService(
path: "/rpc",
initializer: () => new RpcWebsocketSharpBehavior(_server));
}
- ///
- /// Try to set NoDelay flag on the underlying TcpListener to enhance performance on Linux.
- ///
- private void TryToSetNoDelayFlagOnUnderlyingTcpListener()
- {
- var webSocketServerType = _webSocketServer.GetType();
- var listenerPrivateField =
- webSocketServerType.GetField(
- name: "_listener",
- bindingAttr: BindingFlags.NonPublic | BindingFlags.GetField);
-
- if (listenerPrivateField != null)
- {
- if (listenerPrivateField.GetValue(_webSocketServer) is TcpListener tcpListener)
- tcpListener.Server.NoDelay = true;
- }
- }
-
///
/// Start listening for client requests.
///