Cant connect to mqtt-broker because Mono.Unity.UnityTlsContext.ProcessHandshake

Viewed 121

I'm using Unity and want to constantly receive mqtt-data that I can attach to a game object. So I'm trying to enable a connection like this:

async void testconnect()
    {

        const string server = "somewebadress.com";
        const string clientId = "Test";

        var caCert = new X509Certificate2(@"ca.crt");
        var clientCert = new X509Certificate2(@"cert.pfx", "test");

        var source = new CancellationTokenSource();
        var token = source.Token;

        var factory = new MqttFactory();
        var mqttClient = factory.CreateMqttClient();

        var mqttOptions = new MqttClientOptionsBuilder()
            .WithTcpServer(server, 8883)
            .WithClientId(clientId)
            .WithTls(new MqttClientOptionsBuilderTlsParameters
            {
                UseTls = true,
                AllowUntrustedCertificates = true,
                Certificates = new List<X509Certificate> { caCert, clientCert }
            })
            .Build();

        mqttClient.ConnectAsync(mqttOptions, token).Wait(token);
    }

But I'm receiving the following exception:

NotImplementedException: The method or operation is not implemented.

Mono.Unity.UnityTlsContext.ProcessHandshake ()

I've tried to find it out by myself, but I have no clue how to implement the ProcessHandshake() function.

0 Answers
Related