Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebSocket Server is causing the error message below every 5 seconds #736

Open
akramire opened this issue Sep 13, 2023 · 1 comment
Open

Comments

@akramire
Copy link

[9/9/2023 4:37:00 AM] DEBUG <>c__DisplayClass66_0.b__0:791

System.IO.IOException: Authentication failed because the remote party has closed the transport stream.
at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest, Boolean renegotiation)
at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
at WebSocketSharp.Net.WebSockets.TcpListenerWebSocketContext..ctor(TcpClient tcpClient, String protocol, Boolean secure, ServerSslConfiguration sslConfig, Logger log) in D:\WebSocketSharp\websocket-sharp\websocket-sharp\Net\WebSockets\TcpListenerWebSocketContext.cs:line 93
at WebSocketSharp.Server.WebSocketServer.<>c__DisplayClass66_0.b__0(Object state) in D:\WebSocketSharp\websocket-sharp\websocket-sharp\Server\WebSocketServer.cs:line 791

@akramire akramire changed the title WebSocket Server with a HTTP Server is causing the error message below every 5 seconds WebSocket Server is causing the error message below every 5 seconds Sep 13, 2023
@akramire
Copy link
Author

Adding more information about the issue.
As soon as the service starts every 5 seconds the error message happens.

This is the source code.

using System;
using System.Configuration;
using System.Security.Cryptography.X509Certificates;
using WebSocketSharp;
using WebSocketSharp.Server;

namespace Example2
{
public class Program
{
public static void Main (string[] args)
{
// Create a new instance of the WebSocketServer class.
//
// If you would like to provide the secure connection, you should
// create a new instance with the 'secure' parameter set to true or
// with a wss scheme WebSocket URL.
int puerto = int.Parse(ConfigurationManager.AppSettings["Puerto"]);
var wssv = new WebSocketServer (puerto,true);

#if DEBUG
// To change the logging level.
wssv.Log.Level = LogLevel.Trace;
wssv.Log.File = @"C:\log\TraceProtocol.log";
#endif
// To provide the secure connection.

        var cert = ConfigurationManager.AppSettings["ServerCertFile"];
        var passwd = ConfigurationManager.AppSettings["CertFilePassword"];
        wssv.SslConfiguration.ServerCertificate = new X509Certificate2(cert, passwd);
        wssv.SslConfiguration.EnabledSslProtocols = System.Security.Authentication.SslProtocols.Tls12;
        wssv.SslConfiguration.CheckCertificateRevocation = false;
        wssv.SslConfiguration.ClientCertificateRequired = false;
        wssv.SslConfiguration.ClientCertificateValidationCallback = null;
        

      
        // Add the WebSocket services.
        wssv.AddWebSocketService<Echo> ("/Echo");
        wssv.AddWebSocketService<Chat> ("/Chat");

 

  wssv.Start ();

  if (wssv.IsListening) {
    Console.WriteLine ("Listening on port {0}, and providing WebSocket services:", wssv.Port);

    foreach (var path in wssv.WebSocketServices.Paths)
      Console.WriteLine ("- {0}", path);
  }

  Console.WriteLine ("\nPress Enter key to stop the server...");
  Console.ReadLine ();

  wssv.Stop ();
}

}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant