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

How to serve with Hypercorn #176

Closed
realsama opened this issue Mar 19, 2023 · 2 comments
Closed

How to serve with Hypercorn #176

realsama opened this issue Mar 19, 2023 · 2 comments

Comments

@realsama
Copy link

Hello there,

How can I serve my server implementation with Hypercorn? I am getting an "Address already in use" because Hypercorn is bound to the port.

My main looks like below.

async def main(*args, **kwargs):
    async with trio.open_nursery() as nursery:
        nursery.start_soon(listen_redis)

        await serve_websocket(
            echo_server,
            "127.0.0.1",
            5400,
            ssl_context=None,
            handler_nursery=nursery,
        )

All help will be appreciated. Thanks!

@belm0
Copy link
Member

belm0 commented Mar 19, 2023

There was an old ticket #1 asking about how to upgrade an HTTP connection to websocket, but I don't know how to do it.

If you only need a websocket server, I suggest looking at quart-trio, which is built on hypercorn.

If you happen to only need a server, using Quart via the quart-trio
extension may suffice. While trio-websocket is more flexible, Quart covers
both HTTP and WebSocket within a single framework, and serving both from the
same port is straightforward. There has yet to be a performance comparison.

@realsama
Copy link
Author

There was an old ticket #1 asking about how to upgrade an HTTP connection to websocket, but I don't know how to do it.

If you only need a websocket server, I suggest looking at quart-trio, which is built on hypercorn.

If you happen to only need a server, using Quart via the quart-trio
extension may suffice. While trio-websocket is more flexible, Quart covers
both HTTP and WebSocket within a single framework, and serving both from the
same port is straightforward. There has yet to be a performance comparison.

I am more interested in a pure websocket only library sadly. Looks like I will just maintain my starlette implementation for now. Thanks.

@Zac-HD Zac-HD closed this as completed Sep 26, 2023
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