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

NullReferenceException: Object reference not set to an instance of an object #16

Open
dariusjulian opened this issue Oct 6, 2023 · 1 comment
Labels
help wanted Extra attention is needed

Comments

@dariusjulian
Copy link

I'm hoping I can get some help with an issue I'm having.
After running a build for 2-3 hours with no interactivity, I start getting this error and the app no longer receives any data from MQTT.

NullReferenceException: Object reference not set to an instance of an object
  at M2MqttUnity.M2MqttUnityClient.ProcessMqttMessageBackgroundQueue () [0x00016] in <a142f2b118d44b049fd51176acc445ad>:0 
  at M2MqttUnity.M2MqttUnityClient.ProcessMqttEvents () [0x00012] in <a142f2b118d44b049fd51176acc445ad>:0 
  at M2MqttUnity.M2MqttUnityClient.Update () [0x00000] in <a142f2b118d44b049fd51176acc445ad>:0 
  at MyM2MqttUnityScript.Update () [0x00000] in <a142f2b118d44b049fd51176acc445ad>:0 

Any one might be of help as to why this might be happening?

Thanks you in advance.

@tsantor
Copy link

tsantor commented Dec 1, 2023

We're running into this same issue. It seems that ProcessMqttMessageBackgroundQueue is called twice and in the second call it seems for some reason backMessageQueue is null and clear fails?

Our temp workaround is:

private void ProcessMqttMessageBackgroundQueue()
{
    try {
        foreach (MqttMsgPublishEventArgs msg in backMessageQueue) {
            DecodeMessage(msg.Topic, msg.Message);
        }
        backMessageQueue.Clear();
    }
    catch {
        DebugLogger.Log("WARNING: BackMessageQueue is null, reinstantiating the list", DebugErrorTypeEnum.error);
        backMessageQueue = new List<MqttMsgPublishEventArgs>();
    }
    
}

@gpvigano gpvigano added the help wanted Extra attention is needed label Dec 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants