eclipse / paho.mqtt.m2mqtt

Eclipse Public License 1.0
512 stars 303 forks source link

I am facing the UNITYTLS_INVALID_ARGUMENT issue. Unable to resolve it. #134

Open ghost opened 2 years ago

ghost commented 2 years ago

I have added the code snippets stack trace for the issue that I am facing.

For creating client:

                client = new MqttClient(
                        brokerHostName: mqttOptions.hostname,
                        brokerPort: mqttOptions.port,
                        secure: true,
                        caCert: null,
                        clientCert: null,
                        sslProtocol: MqttSslProtocols.SSLv3);

For connection


               client.Connect(
                    clientId: GameLauncher.MqttClientData.clientId,
                    username: GameLauncher.MqttClientData.userName,
                    password: GameLauncher.MqttClientData.password,
                    willRetain: false,
                    willQosLevel: MqttMsgConnect.QOS_LEVEL_EXACTLY_ONCE,
                    willFlag: false,
                    willTopic: "",
                    willMessage: "",
                    cleanSession: mqttOptions.clean,
                    keepAlivePeriod: mqttOptions.keepalive);
Failed to connect to broker:
uPLibrary.Networking.M2Mqtt.Exceptions.MqttConnectionException: Exception connecting to the broker ---> System.AggregateException: One or more errors occurred. ---> Mono.Security.Interface.TlsException: Failed to create UnityTls context - error code: UNITYTLS_INVALID_ARGUMENT
  at Mono.Unity.Debug.CheckAndThrow (Mono.Unity.UnityTls+unitytls_errorstate errorState, System.String context, Mono.Security.Interface.AlertDescription defaultAlert) [0x00027] in <0463b2ef957545c0a51b42f372cd4fbb>:0 
  at Mono.Unity.UnityTlsContext..ctor (Mono.Net.Security.MobileAuthenticatedStream parent, System.Boolean serverMode, System.String targetHost, System.Security.Authentication.SslProtocols enabledProtocols, System.Security.Cryptography.X509Certificates.X509Certificate serverCertificate, System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates, System.Boolean askForClientCert) [0x0029e] in <0463b2ef957545c0a51b42f372cd4fbb>:0 
  at Mono.Unity.UnityTlsStream.CreateContext (System.Boolean serverMode, System.String targetHost, System.Security.Authentication.SslProtocols enabledProtocols, System.Security.Cryptography.X509Certificates.X509Certificate serverCertificate, System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates, System.Boolean askForClientCert) [0x00000] in <0463b2ef957545c0a51b42f372cd4fbb>:0 
  at Mono.Net.Security.MobileAuthenticatedStream+<ProcessAuthentication>d__47.MoveNext () [0x00121] in <0463b2ef957545c0a51b42f372cd4fbb>:0 
   --- End of inner exception stack trace ---
  at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00011] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Threading.Tasks.Task.Wait (System.Int32 millisecondsTimeout, System.Threading.CancellationToken cancellationToken) [0x00043] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at System.Threading.Tasks.Task.Wait () [0x00000] in <695d1cc93cca45069c528c15c9fdd749>:0 
  at Mono.Net.Security.MobileAuthenticatedStream.AuthenticateAsClient (System.String targetHost, System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates, System.Security.Authentication.SslProtocols enabledSslProtocols, System.Boolean checkCertificateRevocation) [0x0000d] in <0463b2ef957545c0a51b42f372cd4fbb>:0 
  at System.Net.Security.SslStream.AuthenticateAsClient (System.String targetHost, System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates, System.Security.Authentication.SslProtocols enabledSslProtocols, System.Boolean checkCertificateRevocation) [0x00006] in <0463b2ef957545c0a51b42f372cd4fbb>:0 
  at uPLibrary.Networking.M2Mqtt.MqttNetworkChannel.Connect () [0x0008a] in D:\UnityProjects\jeet11-rummy\Assets\ThirdParty\M2Mqtt\Net\MqttNetworkChannel.cs:264 
  at uPLibrary.Networking.M2Mqtt.MqttClient.Connect (System.String clientId, System.String username, System.String password, System.Boolean willRetain, System.Byte willQosLevel, System.Boolean willFlag, System.String willTopic, System.String willMessage, System.Boolean cleanSession, System.UInt16 keepAlivePeriod) [0x0001e] in D:\UnityProjects\jeet11-rummy\Assets\ThirdParty\M2Mqtt\MqttClient.cs:562 
   --- End of inner exception stack trace ---
  at uPLibrary.Networking.M2Mqtt.MqttClient.Connect (System.String clientId, System.String username, System.String password, System.Boolean willRetain, System.Byte willQosLevel, System.Boolean willFlag, System.String willTopic, System.String willMessage, System.Boolean cleanSession, System.UInt16 keepAlivePeriod) [0x0002c] in D:\UnityProjects\jeet11-rummy\Assets\ThirdParty\M2Mqtt\MqttClient.cs:566 
  at Custom.Services.WebSockets.BaseMqttClient+<DoConnect>d__16.MoveNext () [0x0010c] in D:\UnityProjects\jeet11-rummy\Assets\Scripts\Common\WebSockets\BaseMqttClient.cs:94 
UnityEngine.Debug:LogErrorFormat (string,object[])
Custom.Services.WebSockets.BaseMqttClient/<DoConnect>d__16:MoveNext () (at Assets/Scripts/Common/WebSockets/BaseMqttClient.cs:109)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
ilsnk commented 1 year ago

u solve this?