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

Send multi-frame messages? #21

Closed
jonozzz opened this issue Jun 26, 2019 · 6 comments
Closed

Send multi-frame messages? #21

jonozzz opened this issue Jun 26, 2019 · 6 comments

Comments

@jonozzz
Copy link

jonozzz commented Jun 26, 2019

Currently I don't see any way to send a message that spans multiple frames.
Briefly looked through the code and await self.asend(BytesMessage(data=bytes(message["bytes"]))) basically initializes a BytesMessage with message_finished=True every time.

Is there a plan to add that? Or am I missing something?

@pgjones
Copy link
Owner

pgjones commented Jun 27, 2019

The ability to specify the framing is not present in the ASGI specification. I think you could make an argument that it should be an ASGI extension. I've opened this issue to get views.

@pgjones
Copy link
Owner

pgjones commented Jun 29, 2019

Could you comment on the ASGI ref issue?

@jonozzz
Copy link
Author

jonozzz commented Jun 30, 2019

Why change the ASGI spec? message.bytes can be an iterable of text or bytes, and in that case it should iterate through it and send BytesMessage(..., message_finished=False) similar to what the websockets lib did here.

@pgjones
Copy link
Owner

pgjones commented Jun 30, 2019

Making the text or bytes an iterable would break one of the ASGI spec assumptions (that each message is complete and immutable). Whilst I could do this, the purpose of Hypercorn is to be an ASGI server, so I don't think it would be the right thing to do. I think the only option is an ASGI extension that allows for this - which would require a motivating use case.

@jonozzz
Copy link
Author

jonozzz commented Jun 30, 2019

If that's the case then there should be a note in the documentation disclosing that hypercorn/quart doesn't fully implement the websockets protocol (rfc6455), in particular the continuation frames, so that whoever wants to use these libs is aware of the limitation.

The most obvious use case is server sending a message of unknown length (e.g. streams like compressed files, live media streaming, etc.) or buffered large file transfers. In my case I was only testing the protocol and was hoping that I'd get the same functionality as with the websockets library.

@pgjones
Copy link
Owner

pgjones commented Jul 4, 2019

I think the documentation is sufficient, in that Hypercorn claims to be an ASGI compliant server rather than a complete WebSocket server.

I think there is a case for this being an ASGI extension though, it does require convincing others in the ASGI issue though.

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