Closed RaghuMudem closed 5 months ago
The code in question is doing this -
// Drop the connection if our connect request has been rejected.
if (MqttReasonCodeUtilities.isError(
mqttConnectReasonCode.asInt(ackMsg.variableHeader!.reasonCode)!)) {
Its looking for the reason code in the connect ack message and not finding it, or its not an int, your broker should always set this, even on a good connection. That said this code is messy, I'll update it to remove the null checks or log on failure so we can see better what is happening.
OK I've tidied this up and added logging to show exactly where the reason code processing is failing. Package re published at version 4.2.2, upgrade to this and see how you go now.
Flutter application is using the mqtt5_client package. And it works normal.
We have a common crash handler in our flutter application. But our crash handler reporting huge number of crashes in to firebase crashlitics. Firebase logs are added below. And we started investigating the issue, even we reproduced this issue there is 2 development logs added below.
From the local logs it is disconnected somehow and as printed in the crash log and it connected again. We are trying to find the reson and fix for this issue. But as it is happening in the package, we seek your support in this issue to resolve.
Environment details:
mqtt5_client: ^4.0.3 Flutter 3.16.3 Dart 3.2.3 DevTools 2.28.4
Firebase crash logs:
Development logs:
Logs 1#
W/m.demo.ap(25603): Accessing hidden method Lsun/misc/Unsafe;->putLong(Ljava/lang/Object;JJ)V (greylist, linking, allowed) W/m.demo.ap(25603): Accessing hidden method Lsun/misc/Unsafe;->putLong(Ljava/lang/Object;JJ)V (greylist, linking, allowed) W/m.demo.ap(25603): Accessing hidden method Lsun/misc/Unsafe;->putLong(Ljava/lang/Object;JJ)V (greylist, linking, allowed) I/flutter (25603): ----------------FIREBASE CRASHLYTICS---------------- I/flutter (25603): Null check operator used on a null value I/flutter (25603): I/flutter (25603): #0 MqttConnectionHandlerBase.connectAckProcessor (package:mqtt5_client/src/connectionhandling/mqtt_connection_handler_base.dart:274:73) I/flutter (25603): #1 MqttConnectionHandlerBase.connectAckReceived (package:mqtt5_client/src/connectionhandling/mqtt_connection_handler_base.dart:304:5) I/flutter (25603): #2 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10) I/flutter (25603): #3 CastStreamSubscription._onData (dart:_internal/async_cast.dart:85:11) I/flutter (25603): #4 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10) I/flutter (25603): #5 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11) I/flutter (25603): #6 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7) I/flutter (25603): #7 _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:123:11) I/flutter (25603): #8 _WhereStream._handleData (dart:async/stream_pipe.dart:195:12) I/flutter (25603): #9 _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13) I/flutter (25603): #10 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10) I/flutter (25603): #11 _BufferingStreamSubscription._sendData (dart:async/stream_impl I/flutter (25603): ---------------------------------------------------- I/flutter (25603): Mqtt: CONNECTED I/flutter (25603): _streamChangeController I/flutter (25603): Content source: [] W/m.demo.ap(25603): Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed) W/m.demo.ap(25603): Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed) I/flutter (25603): Mqtt: OnDisconnected client callback - Client disconnection I/flutter (25603): Mqtt: CONNECTED I/System.out(25603): (HTTPLog)-Static: isSBSettingEnabled false I/System.out(25603): (HTTPLog)-Static: isSBSettingEnabled false I/flutter (25603): Mqtt: 11:59:54 - KEEPALIVE I/flutter (25603): Mqtt: OnDisconnected client callback - Client disconnection I/flutter (25603): Mqtt: CONNECTED
Logs 2#
I/flutter (31360): Mqtt: CONNECTED I/flutter (31360): _streamChangeController I/flutter (31360): Content source: [] W/m.demo.ap(31360): Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed) W/m.demo.ap(31360): Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed) W/m.demo.ap(31360): Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, linking, allowed) W/m.demo.ap(31360): Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed) W/m.demo.ap(31360): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed) I/flutter (31360): Mqtt: OnDisconnected client callback - Client disconnection I/flutter (31360): Mqtt: CONNECTED I/flutter (31360): ----------------FIREBASE CRASHLYTICS---------------- I/flutter (31360): Null check operator used on a null value I/flutter (31360): I/flutter (31360): #0 MqttConnectionHandlerBase.connectAckProcessor (package:mqtt5_client/src/connectionhandling/mqtt_connection_handler_base.dart:274:73) I/flutter (31360): #1 MqttConnectionHandlerBase.connectAckReceived (package:mqtt5_client/src/connectionhandling/mqtt_connection_handler_base.dart:304:5) I/flutter (31360): #2 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10) I/flutter (31360): #3 CastStreamSubscription._onData (dart:_internal/async_cast.dart:85:11) I/flutter (31360): #4 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10) I/flutter (31360): #5 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11) I/flutter (31360): #6 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7) I/flutter (31360): #7 _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:123:11) I/flutter (31360): #8 _WhereStream._handleData (dart:async/stream_pipe.dart:195:12) I/flutter (31360): #9 _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13) I/flutter (31360): #10 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10) I/flutter (31360): #11 _BufferingStreamSubscription._sendData (dart:async/stream_impl I/flutter (31360): ---------------------------------------------------- I/flutter (31360): Mqtt: OnDisconnected client callback - Client disconnection I/flutter (31360): Mqtt: 14:24:21 - KEEPALIVE I/flutter (31360): Mqtt: CONNECTED I/TRuntime.CctTransportBackend(31360): Making request to: https://firebaselogging-pa.googleapis.com/v1/firelog/legacy/batchlog I/System.out(31360): (HTTPLog)-Static: isSBSettingEnabled false I/System.out(31360): (HTTPLog)-Static: isSBSettingEnabled false I/TRuntime.CctTransportBackend(31360): Status Code: 200 W/m.demo.ap(31360): Accessing hidden method Lsun/misc/Unsafe;->putLong(Ljava/lang/Object;JJ)V (greylist, linking, allowed) I/flutter (31360): Mqtt: 14:24:51 - KEEPALIVE