shamblett / mqtt5_client

A server and browser based MQTT 5 client for dart
Other
50 stars 26 forks source link

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

Closed gawie-kellerman closed 1 year ago

gawie-kellerman commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

May have fixed this please try version 3.3.5

gawie-kellerman commented 1 year ago

Hi Steve,

Thanks, will give it a go over the weekend.

Regards, Gawie

On Fri, 27 Jan 2023, 18:22 Steve Hamblett, @.***> wrote:

May have fixed this please try version 3.3.5

— Reply to this email directly, view it on GitHub https://github.com/shamblett/mqtt5_client/issues/38#issuecomment-1406730056, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD2NHRJ5JRWEVGXLNEBN3B3WUPY3XANCNFSM6AAAAAASY6MLTM . You are receiving this because you authored the thread.Message ID: @.***>

shamblett commented 1 year ago

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

shamblett commented 1 year ago

Closing, presumed fixed.