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

Update websocket implementation over MQTT to not send multiple ws frames for a single MQTT packet #1873

Merged
merged 1 commit into from
Apr 6, 2021

Conversation

abhipsaMisra
Copy link
Member

@abhipsaMisra abhipsaMisra commented Apr 1, 2021

This PR updates our websocket implementation over MQTT to send a single ws frame per MQTT packet being sent.

In short - our websocket implementation sent each message dequeued from the ChannelOutboundBuffer individually, which sometimes resulted in multiple messages being sent for a single MQTT packet (eg. PUBLISH packet encodes the topic and payload separately, so they would show up as different tcp packets on the wire). The fix is to dequeue all enqueued messages and consolidate them before writing to websocket.

I have added the comments in the code explaining the fix, let me know if something is unclear and I can update it.
Fix for #1814

This github issue also contains some details: Azure/DotNetty#553

// - The property ReferenceCount of a byte buffer implementation maintains a counter of the no of messages available for dequeueing.
// A ReferenceCount of 0 indicates that all messages have been flushed and the buffer can be deallocated.
// By calling the method Retain() on each byte buffer component added to the CompositeByteBuffer,
// we increase the ReferenceCount by 1 and mark them as ready for dequeuing.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the spelling of dequeuing here is different than the one on line 291. Not sure which one is right :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably this one?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoops, "dequeuing" (so many extra alphabets just sitting there needlessly)

… to not send multiple ws frames for a single MQTT packet
@abhipsaMisra
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@abhipsaMisra abhipsaMisra merged commit 0727647 into master Apr 6, 2021
@abhipsaMisra abhipsaMisra deleted the abmisr/mqttWsByffer branch April 6, 2021 22:06
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

Successfully merging this pull request may close these issues.

None yet

3 participants