Phx_raws - Raw websocket on top of Phoenix

In a Phoenix-based project, it is rather tedious to get a raw cowboy websocket working manually, as one is required to set-up a custom dispatch as well as to handle the socket itself. Therefore, after a few hours of testing and reading through the source code, I have come up with a solution that follows Phoenix’ semantics nicely.


Contributions are more than welcome, especially to keep it updated and prevent it from breaking as Phoenix continues to evolve.


Nice! People have been asking for this many times. Maybe the handle callback should be named handle_in to match Phoenix Channel API?


I think handle suits better as a generic name, as it does receive both incoming data and a few events. Plus switching to _in would only make sense if there was an _out counterpart, which is not the case.

Would like to hear more comments on this :slight_smile:

On events (i.e. :closed), I thought adding a separate callback for them would be a bit overkill - which is why they’re dispatched through the same generic callback, what do you think?

1 Like