Closed RaghuMudem closed 1 month ago
Yes you are correct, the error suggests that the client has received an invalid reason code somehow, I'll have a look at this but as you say this is only in a toString method so if no other solution is found I'll trap this error here and substitute a suitable error string. I should have this done over the next few days.
OK, try it now, package re released at version 4.2.5
Hi,
Thank you for your quick response.
Updated Version Behavior:
I tested the updated version (mqtt5_client: ^4.2.5) and observed the following behavior:
Calling connect on MqttServerClient without username and password no longer throws the error I reported earlier. The connection state now simply shows as MqttConnectionState.connected without any error code or message. Previous Version Behavior:
In version 4.2.2, the same scenario correctly threw the error message as i mentioned in my question.
Expected Behavior (May be):
When attempting to connect method (MqttServerClient->connect(..)) without proper credentials, the library should ideally:
Return a descriptive error message or code indicating the issue. Set the connection state to MqttConnectionState.faulted. Attached Screenshots:
Please check the attached screen with my debug values while using version 4.2.5.
Thank you for considering this fix. It would improve the clarity of error handling in the library.
OK, seems reasonable, I'll have a look at this.
Just a question, when you say 'without proper credentials...' what do you mean. The client doesn't know you need credentials, lost of brokers work with just a client id say and no username/password, so in this case if theses weren't supplied how would the client know they are needed by the broker and take appropriate action
Dear Author,
We're incorporating the mqtt5_client library (version ^4.2.2) into our Flutter application (version 3.19.5 with Dart 3.3.3) and experiencing a non-fatal exception reported through Firebase Crashlytics.
Error:
The error message indicates a RangeError (length): Invalid value: Only valid value is 0: 1 within the MqttEnumHelper class's asString method. This suggests an attempt to access an element at an invalid index (1) in a list or similar construct that only has one element (0).
Analysis:
We've analyzed the logs and believe the issue might lie with unexpected values being passed to the asString method in the class MqttEnumHelper.
Request:
We'd appreciate your guidance on how to address this error. Ideally, we'd like to understand:
Are there potential client-side fixes we can implement to handle this unexpected value scenario? Is this a potential bug within the mqtt5_client library that could be addressed in a future update?
Additional Information:
Development Environment: Android Studio (JellyFish) IDE Code Snippet (if applicable): MqttEnumHelper.asString(..) method call. Logs:
Sincerely, Raghu