WebSocket4Net
WebSocket4Net copied to clipboard
Unable to connect in .NET Framework v4.8
Environment: Windows 10 Pro 64bit WebSocket4Net v0.15.2 (from NuGet package) .NET Framework v4.8
Issue: I use WebSocket4Net for a few months and everything worked well until November, 19th 2021. Since that date all my utilities can not establish web-socket connection with counterparties. Administration of servers assures they did not change anything on server side.
When I call ws.Open() I always receive the same exception:
System.Security.Authentication.AuthenticationException: A call to SSPI failed, see inner exception. ---> System.ComponentModel.Win32Exception: The function requested is not supported --- End of inner exception stack trace --- at System.Net.Security.SslState.InternalEndProcessAuthentication(LazyAsyncResult lazyResult) at System.Net.Security.SslState.EndProcessAuthentication(IAsyncResult result) at SuperSocket.ClientEngine.SslStreamTcpSession.OnAuthenticated(IAsyncResult result)
Sample code to reproduce the issue: ` using System; using System.Net; using System.Threading;
using WebSocket4Net;
namespace TestWebsocket4net { class Program { static void Main(string[] args) { ServicePointManager.Expect100Continue = true; // https://docs.microsoft.com/ru-ru/dotnet/api/system.security.authentication.sslprotocols?view=net-6.0 ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls13 | SecurityProtocolType.SystemDefault;
WebSocket ws = new WebSocket("wss://ws.okex.com:8443/ws/v5/public", "", version: WebSocketVersion.None, receiveBufferSize: 2 * WebSocket.DefaultReceiveBufferSize);
ws.AutoSendPingInterval = 5;
ws.EnableAutoSendPing = true;
ws.Error += (s, e) => Console.WriteLine(e.Exception);
ws.Opened += (s, e) => Console.WriteLine("Opened!");
ws.Open();
DateTime beg = DateTime.UtcNow;
while (ws.State != WebSocketState.Open)
{
Thread.Sleep(50);
if ((DateTime.UtcNow - beg).TotalSeconds > 7 * ws.AutoSendPingInterval)
throw new TimeoutException($"Unable to open connection? For {7 * ws.AutoSendPingInterval} seconds? What's going on?");
}
}
}
} `