From ad80ef21c87a37337f907364355a62bff13a2022 Mon Sep 17 00:00:00 2001 From: flashwave Date: Sun, 10 Apr 2022 18:49:40 +0200 Subject: [PATCH] Fixed read timeout issue. --- Hamakaze/HttpConnection.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Hamakaze/HttpConnection.cs b/Hamakaze/HttpConnection.cs index 509a6b6..c7eda62 100644 --- a/Hamakaze/HttpConnection.cs +++ b/Hamakaze/HttpConnection.cs @@ -13,6 +13,9 @@ namespace Hamakaze { private Socket Socket { get; } + private NetworkStream NetworkStream { get; } + private SslStream SslStream { get; } + public string Host { get; } public bool IsSecure { get; } @@ -39,19 +42,19 @@ namespace Hamakaze { }; Socket.Connect(endPoint); - Stream stream = new NetworkStream(Socket, true); + NetworkStream = new NetworkStream(Socket, true); if(IsSecure) { - SslStream sslStream = new SslStream(stream, false, (s, ce, ch, e) => e == SslPolicyErrors.None, null); - Stream = sslStream; - sslStream.AuthenticateAsClient( + SslStream = new SslStream(NetworkStream, false, (s, ce, ch, e) => e == SslPolicyErrors.None, null); + Stream = SslStream; + SslStream.AuthenticateAsClient( Host, null, SslProtocols.Tls11 | SslProtocols.Tls12 | SslProtocols.Tls13, true ); } else - Stream = stream; + Stream = NetworkStream; } public void MarkUsed() { @@ -73,6 +76,9 @@ namespace Hamakaze { throw new HttpConnectionAlreadyUpgradedException(); HasUpgraded = true; + NetworkStream.ReadTimeout = -1; + SslStream.ReadTimeout = -1; + return new WsConnection(Stream); }