1

09.02.2021 15:26:21|Fatal|WebSocket.connect|WebSocketSharp.WebSocketException: An error has occurred during a TLS handshake. ---> System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception. ---> System.ComponentModel.Win32Exception (0x80090302): Указанная функция не поддерживается --- End of inner exception stack trace --- at System.Net.Security.SslStream.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, ExceptionDispatchInfo exception) at System.Net.Security.SslStream.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest) at System.Net.Security.SslStream.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest) at System.Net.Security.SslStream.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest) at System.Net.Security.SslStream.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest) at System.Net.Security.SslStream.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest) at System.Net.Security.SslStream.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest) at System.Net.Security.SslStream.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest) at System.Net.Security.SslStream.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest) at System.Net.Security.SslStream.ProcessAuthentication(LazyAsyncResult lazyResult, CancellationToken cancellationToken) at System.Net.Security.SslStream.AuthenticateAsClient(SslClientAuthenticationOptions sslClientAuthenticationOptions) at System.Net.Security.SslStream.AuthenticateAsClient(String targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, Boolean checkCertificateRevocation) at WebSocketSharp.WebSocket.setClientStream() --- End of inner exception stack trace --- at WebSocketSharp.WebSocket.setClientStream() at WebSocketSharp.WebSocket.doHandshake() at WebSocketSharp.WebSocket.connect() 09.02.2021 15:26:21|Error|WebSocket.Send|This operation isn't available in: closed```

This my exeption track. if i try send http requests to websocket handhskake, all ok 101 But if i try connect to wsSharp, i get Exeptions MY CODE:

using (var ws = new WebSocket("wss://ws-gate.fxclub.org/ws")) { 
//ws.SslConfiguration.EnabledSslProtocols = System.Security.Authentication.SslProtocols.Tls13;

        ws.OnMessage += (sender, e) =>
                    Console.WriteLine("Laputa says: " + e.Data);

        ws.Connect();
        ws.Send(secWebSocketKey);
        Console.ReadKey(true);
    }
ggeorge
  • 1,496
  • 2
  • 13
  • 19

1 Answers1

-1

Is TLS v1.3 enabled (for your 'Client') upon your machine (maybe?) - have you tried with TLS v1.2 (and even TLS v1.1) (?). Or perhaps due to a (websocket) timeout (- that can especially occur more often/easily happen when pausing for thought/analysis during debugging).

It appears that when it checks if the connection is available, and the ready-state is set to ('WebSocketState') 'Closed', it reports the error "This operation isn't available in: closed".

It's probably worth checking your certificates (/client certificate). Have you tried temporarily disabling the client and/or server certificate validation (?) - in case it sheds some light / gives you a clue. My money (/guess) is upon the certificates being the most likely/general cause.

Probably/generally less likely a concern, but does the cert/s match-up/comply with the enabled ciphers upon your client (/and server machine) (? - maybe someone has disabled insecure ciphers upon one of the machines).

Have you explicitly set the 'EnabledSslProtocols' property (- rather than it falling-back to 'Default' which is supposedly the old options of Tls v1.0 & Ssl3)?

Have you run both the client & server (elevated/run-)as 'Administrator'/with Administrator rights/permissions (?).

Does your server cert contain a private key?

Knowing the specific version of 'WebSocket-Sharp' that you're using could possibly prove useful to know (- ?).

As TLS (& SSL) and with certs in the mix, it can be a technical subject to deal with/predict (- I can't say for 100% sure), but you could consider temporarily enabling more extensive logging for Windows 'SCHANNEL'/TLS - (for the brave/careful - you should always back-up your Windows registry first before apply changes) via the Windows Registry, to see if it captures a/some future detail/s:

SCHANNEL TLS/SSL logging - 1=error, 2=warning; error & warning = 3; in the "System" log

  • Bitwise OR; e.g. value of '7'

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\SecurityProviders\SCHANNEL\EventLogging

Value Description

0x0000 Do not log 0x0001 Log error messages 0x0002 Log warnings 0x0004 Log informational and success events

DennisVM-D2i
  • 416
  • 3
  • 8
  • Please phrase this as an explained conditional answer, in order to avoid the impression of asking a clarification question instead of answering (for which a comment should be used instead of an answer, compare https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead ). For example like "If your problem is ... then the solution is to .... because .... ." – Yunnosch Jan 04 '23 at 17:54
  • Your answer is vague and depends on "is", or "what if"; please write a comment instead - you have the reputation, and it appears this post is asking for clarification more than providing an answer. – Ollie Jan 06 '23 at 16:01