doghappy / socket.io-client-csharp

socket.io-client implemention for .NET
MIT License
729 stars 125 forks source link

Unity SocketIOClient cannot connect SSL Server on Android #383

Open ZFHung opened 1 month ago

ZFHung commented 1 month ago
       Unity Error,how to pass SSL errors

       Assets\Socket_Manager.cs(107,28): error CS0029: Cannot implicitly convert type 'System.Net.WebSockets.ClientWebSocket' to 'SocketIOClient.Transport.IClientWebSocket'

       client = new SocketIOUnity("wss://xxxx", new SocketIOOptions
       {
           ReconnectionAttempts = 5,
       });
       client.ClientWebSocketProvider = () =>
       {
           var clientWebSocket = new ClientWebSocket();
           clientWebSocket.Options.RemoteCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) =>
           {
               Console.WriteLine("SslPolicyErrors: " + sslPolicyErrors); 
               return true;
           };
           return clientWebSocket;
       };
doghappy commented 3 weeks ago

The new version was released. if you want to ignore ssl validation:

var io = new SocketIO("https://localhost:11404", new SocketIOOptions
{
    RemoteCertificateValidationCallback = (_, _, _, _) =>
    {
        return true;
    }
});
ZFHung commented 3 weeks ago

I use this code ,still cannot coonect to the Socket Server。how can i fix?

var io = new SocketIO("https://localhost:11404", new SocketIOOptions { RemoteCertificateValidationCallback = (, , , ) => { return true; } });

doghappy commented 1 week ago

Sorry. I'm too late.

First try to update lib to latest version, if you still blocked by compiling errors. please show error messages