You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a custom broker using mqtt-connection that crashed today because it received a packet that generated a "wrong subscribe header" error.
I think this is what happened:
mqtt-packet tried to parse the packet, emitted an error event, then emitted a packet event.
mqtt-connection forwarded the error event to me and converted the packet event into a subscribe event.
Since the whole packet wasn't parsed, the subscriptions property was undefined. That's where my broker crashed.
IMO, Parser.parse() should skip emitting the packet event as soon as it encounters an error because it seems strange for me to have to validate the packet that mqtt-packet already determined was invalid.
Since the MQTT spec says connections should be closed on protocol violations, maybe Parser.parse() should stop parsing completely when it encounters an error in case there are more packets in the buffer. This would stop mqtt-connection from continuing to emit packets that shouldn't be processed.
If you agree, I can send a PR but I think this is a backwards incompatible change to the API so would require a major bump.
The text was updated successfully, but these errors were encountered:
I think that is a bug, both here (it should emit more parse events) and in mqtt-connection (it should close the connection on a parse error). Would you mind to send a couple of PRs?
I have a custom broker using mqtt-connection that crashed today because it received a packet that generated a "wrong subscribe header" error.
I think this is what happened:
subscriptions
property was undefined. That's where my broker crashed.IMO,
Parser.parse()
should skip emitting the packet event as soon as it encounters an error because it seems strange for me to have to validate the packet that mqtt-packet already determined was invalid.Since the MQTT spec says connections should be closed on protocol violations, maybe
Parser.parse()
should stop parsing completely when it encounters an error in case there are more packets in the buffer. This would stop mqtt-connection from continuing to emit packets that shouldn't be processed.If you agree, I can send a PR but I think this is a backwards incompatible change to the API so would require a major bump.
The text was updated successfully, but these errors were encountered: