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

InvalidHeaderException (Header must be at least 2 bytes long) #38

Closed
gawie-kellerman opened this issue Dec 9, 2022 · 6 comments
Closed

Comments

@gawie-kellerman
Copy link

Hello,

I am getting the following error seemingly random - but on connection.

mqtt-client::InvalidHeaderException: The supplied header is invalid. Header must be at least 2 bytes long.

It does not stop the code from working - but obviously leaves one worried to the underlying issue.

Call Stack:
MqttHeader.readFrom (package:mqtt5_client/src/messages/mqtt_header.dart:69:7)
#1 new MqttHeader.fromByteBuffer (package:mqtt5_client/src/messages/mqtt_header.dart:19:5)
#2 MqttByteBuffer.isMessageAvailable (package:mqtt5_client/src/utility/mqtt_byte_buffer.dart:66:29)
#3 MqttServerConnection._onData (package:mqtt5_client/src/connectionhandling/server/mqtt_server_connection.dart:60:26)
#4 _RootZone.runUnaryGuarded (dart:async/zone.dart:1586:10)
#5 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#6 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#7 _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774:19)
#8 _StreamController._add (dart:async/stream_controller.dart:648:7)
#9 _StreamController.add (dart:async/stream_controller.dart:596:5)
#10 _Socket._onData (dart:io-patch/socket_patch.dart:2324:41)
#11 _RootZone.runUnaryGuarded (dart:async/zone.dart:1586:10)
#12 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#13 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#14 _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774:19)
#15 _StreamController._add (dart:async/stream_controller.dart:648:7)
#16 _StreamController.add (dart:async/stream_controller.dart:596:5)
#17 new _RawSocket. (dart:io-patch/socket_patch.dart:1849:33)
#18 _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:1322:14)
#19 _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#20 _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
#21 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:122:13)
#22 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:193:5)

@shamblett
Copy link
Owner

OK, when you say 'on connection' do you mean on first connection, i.e. you have not connected before or on subsequent connections after disconnects. If the input buffer is corrupt somehow then it can't be on first connection as its clean, it maybe after this.

Are you seeing any other exceptions when in use?

@gawie-kellerman
Copy link
Author

Hi Steve,

Thank you for the response (which definitely helped). You are correct, the issue is on the second or third connection attempt - which leads me to believe that it is a resource disposal/synchronous issue - with good certainty that it is likely on my end.

Regards and thanks again, Gawie

@shamblett
Copy link
Owner

May have fixed this please try version 3.3.5

@gawie-kellerman
Copy link
Author

gawie-kellerman commented Jan 27, 2023 via email

@shamblett
Copy link
Owner

Version 3.3.6 released, please check if this fixes the problem.

@shamblett
Copy link
Owner

Closing, presumed fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants