-
Notifications
You must be signed in to change notification settings - Fork 302
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
Add websocket support for swoole #110
Comments
In case anyone wants any reference, I've begun implementing this functionality in a fork forestlovewood/octane – I'm aiming to achieve integration with Broadcasting/Notifications, utilising native authentication and event handling. |
@forestlovewood Are you also thinking about implementing a backplane (like Redis) to support replication and HA-scenarios? |
That should be reasonably straightforward, I was going to use Swoole Tables but I should be able to use Redis as well with little modification. I've actually never used replicated WebSocket servers, though, so I don't know if there's any gotchas. |
Maybe easier to use https://github.com/beyondcode/laravel-websockets as base? Not sure how hard it would be to create an alternative server for it, besides React? (cc @mpociot) |
Agreed, at this point I'm just implementing the basic functionality and event handling in Octane, so it might make sense to also fork Laravel WebSockets and see if I could add Octane integration. |
I actually started working on an Octane compatible version of Laravel WebSockets myself 😅 |
Cool :) Yeah that's what I meant. No real reason for it to be in Octane, more likely to be in Laravel Websockets where you can start it with |
Well, the question is if two processes are really required. Especially in a containerized environment, a single process would be a lot easier to setup and maintain. Two processes means you'd need an extra (public) port or a reverse proxy to split HTTP from WS traffic. Whether it makes sense to put both into a single process and container depends heavily on the exact use case though. High-traffic sites may have an argument to split these use cases for independent scalability. I support the idea of a separate package (even if that makes the upgrade harder), but I would prefer a plug-in solution where Octane runs the package implementation. |
I like the idea of both options – perhaps having some basic functionality built into Octane, but also having the ability to have a distinct server running just for Laravel Websockets? I still like the idea of a simple Broadcasting driver built into Octane, though, along with a Queue driver and a Scheduler driver. It'd be nice to be able to use it nearly self-contained like that.
Yeah, that's the changes I've made so far in my fork, working on integrating the raw events with Octane in a way that could likely be hooked into fairly easily by a package like Laravel Websockets. |
Since a few people are working on this as a package I will close this for now - I would be very interested in checking out any packages that support it! |
@taylorotwell It might make more sense for it to be in Octane itself. This is because This seems to be the approach that @forestlovewood was using in his fork, although I'm not sure if he's actively working on it. If this were implemented as an external package, it wouldn't be able to run both traditional HTTP and WebSockets on the same connection (over the same port). This would decrease the usefulness, and might make it more difficult to implement on some cloud providers. One approach might be to make it possible to customize in the configuration which Swoole server class to use, and then it would be simpler to implement as a third-party plugin. This would still require some changes to Octane itself, though. Would you be open to a PR to that effect? |
It might even make sense for the |
+1 🙏 need WebSockets in octane |
My solution so far (from a 2nd github account) based on @forestlovewood's initial work: No guarantees that I will keep maintaining this fork/branch. You're welcome to clone/fork/maintain your own. You'll need to tweak your
Don't forget to |
We are in dire need of a bi-directional websocket solution to build amazing applications. Some solutions exist, such as laravel-swoole and laravel-s, but they have terrible support and outdated or missing documentation. We must to move things around somehow |
I switched from Laravel to Hyperf Until then, it's Hyperf for me |
Hey it's been a while |
So sorry 😭 I think i'm abandoning it again #977 (comment) |
Seeing as Swoole supports websockets out of the box, it would be cool to have this as a configurable option.
I had a quick play and simply changing
Swoole\Http\Server
toSwoole\Websocket\Server
inbin/createSwooleServer.php
appears to mostly work - I also had to define at least a singleon("message")
handler as well inbin/swoole-server
before the server is started.The only roadblock I can think of is that I imagine @taylorotwell you may prefer it if websockets were tied in with native laravel auth/ event stuff? Currently it would be only raw socket messaging.
The text was updated successfully, but these errors were encountered: