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 handle websocket request simultaneously? #320

Closed
gamelife1314 opened this issue May 28, 2018 · 2 comments
Closed

How to handle websocket request simultaneously? #320

gamelife1314 opened this issue May 28, 2018 · 2 comments

Comments

@gamelife1314
Copy link

I want to start a server that can handle http request and websocket request simultaneously by reacthttp.

Does anybody have any ideas to help me ?

@clue
Copy link
Member

clue commented May 28, 2018

Hi @gamelife1314, thank you for this excellent question!

This project does indeed support using Connection: upgrade to support any kind of (custom) protocol over HTTP. Example 32 shows how this can be used with a custom "chat" protocol, but there's nothing that prevents this from being used with WebSockets.

If you want a pure WebSocket server, Ratchet is a good choice. I'm not sure if there's any project that supports running a normal HTTP server along with a WebSocket server on the same port, but I recall several people working on this.

The closest I found find is https://gist.github.com/mbonneau/821096940a0f32091f6475c404697193 from #159 and https://github.com/voryx/WebSocketMiddleware from https://github.com/reactphp/http/wiki/Middleware. Maybe @mbonneau or @davidwdan can give some more input on this? 👍

I hope this helps 👍

I believe this has been answered, so I'm closing this for now. Please come back with more details if this problem persists and we can reopen this 👍

@clue clue closed this as completed May 28, 2018
@mbonneau
Copy link

@gamelife1314 https://github.com/voryx/WebSocketMiddleware can be used in your middleware stack along with regular http requests.

See https://github.com/voryx/WebSocketMiddleware/blob/master/example/chat_ws_server.php for an example that serves both static content on http with a simple WebSocket chat server on the same port.

Also, https://github.com/thruway/middleware allows you to run the WAMP protocol as middleware (a pub/sub/rpc protocol that can run over WebSockets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants