Skip to content

Support fragmented messages #108

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

Open
piegamesde opened this issue Sep 12, 2022 · 4 comments
Open

Support fragmented messages #108

piegamesde opened this issue Sep 12, 2022 · 4 comments

Comments

@piegamesde
Copy link

I have the use case where I have to send a message of X bytes, and I know X in advance, but it is fairly large so I'd like to not have to have the entire message in memory beforehand. Instead, I'd like to lazily generate it in small chunks as they are being sent. (Of course there will need to be a check afterwards that exactly as many bytes as advertised were sent)

Would such a feature be feasible?

Similarly, but also less importantly, what about that feature for the reading direction?

@sdroege
Copy link
Owner

sdroege commented Sep 12, 2022

That sounds useful but I'm not sure how easy that would be to implement. I think it will also requires changes to tungstenite as that also operates in messages instead of plain bytes. If you want to take a look at this in more detail, please go ahead :)

From the application side, if you have the choice, you could split the huge message into smaller messages with a small header that allows you to reconstruct them again.

@piegamesde piegamesde changed the title Send/receive messages in parts Support fragmented messages Sep 12, 2022
@piegamesde
Copy link
Author

So apparently tungstenite already supports the feature. I have no idea about how to expose this in an async API though. For my use case, the length is already known beforehand which arguably makes it a bit easier, but the full feature seems to support messages of previously unknown length.

@sdroege
Copy link
Owner

sdroege commented Sep 13, 2022

Yeah I'm not sure either. This needs some design time :) Also it seems like tokio-tungstenite doesn't support this yet either.

@joshtriplett
Copy link
Contributor

@piegamesde

So apparently tungstenite already supports the feature.

Could you elaborate on how tungstenite supports this? I'm not familiar with that support.

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

3 participants