Search Unity

M2Mqtt crashes oculus app

Discussion in 'Multiplayer' started by unity_WV5mX4H7zrN5GA, May 13, 2020.

  1. unity_WV5mX4H7zrN5GA

    unity_WV5mX4H7zrN5GA

    Joined:
    Apr 2, 2020
    Posts:
    3
    Hey,

    i am just want to use the mqtt functionality of the m2mqtt package. I imported the downloaded .dll file into the assets and used this snip of code to connect & send:

    Code (CSharp):
    1. using System;
    2. using UnityEngine;
    3. using uPLibrary.Networking.M2Mqtt;
    4. using uPLibrary.Networking.M2Mqtt.Messages;
    5.  
    6. public class SendSomething : MonoBehaviour
    7. {
    8.     MqttClient client = new MqttClient("192.168.178.22");
    9.     string clientId = Guid.NewGuid().ToString();
    10.     // Start is called before the first frame update
    11.     void Start()
    12.     {
    13.         string clientId = Guid.NewGuid().ToString();
    14.         client.Connect(clientId);
    15.         //client.MqttMsgPublishReceived += ClientOnMqttMsgPublishReceived;
    16.  
    17.         // Subscribe to topic
    18.         //client.Subscribe(new[] { "/testing" }, new[] { MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE });
    19.     }
    20.  
    21.     private static void ClientOnMqttMsgPublishReceived(object sender, MqttMsgPublishEventArgs e)
    22.     {
    23.         var message = System.Text.Encoding.Default.GetString(e.Message);
    24.         Console.WriteLine("Message received: " + message);
    25.     }
    26.  
    27.     // Update is called once per frame
    28.     void Update()
    29.     {
    30.         //var enc = new System.Text.ASCIIEncoding();
    31.         //var message = enc.GetBytes("message");
    32.  
    33.         //client.Publish("time",message);
    34.     }
    35. }
    36.  
    In Unity the code and the MQTT-Function works well. But after deploying on the oculus quest device the homescreen with the "Made with Unity"-Sign is shown for a few seconds. After that, the Sign disappeares and the screen is freezing.
    It must me something at the "connect", because when i am commenting out the "connect" everything is working normally.

    Can anybody help me?

    Thanks for all,
    Matthias