Phoenix websocket url pattern

Hello
Is there any way in phoenix to have websockets with this pattern
http://localhost:3000/api/[uuid]
Something like that
http://localhost:3000/api/368c1ce7-5b89-4beb-8e3f-1fcc6eec6506
I’m using a JavaScript api to upload files and it uses web sockets for realtime feed to the client while upload is going on
but JavaScript client doesn’t match with Phoenix web sockets.

Any idea would be appreciate

I’m not sure I understand the problem. Are you trying to connect to a websocket endpoint with the above pattern? Is there a reason you can’t connect directly to the url with the uuid?

Yes Phoenix channels seem to need network protocol as suffix.
This URL works fine
http://localhost:3000/api/websocket
Or even
http://localhost:3000/api/[uuid]/websocket

I would like to avoid this suffix, maybe redirecting or with some route,
but I can’t figure it out.
Thanx

You can do it but you’d have to make your own websocket override module, it is actually very easy to do and involves mostly copying the existing module. :slight_smile:

Hello OvermindDL1
Do you mean this phoenix module: Phoenix.Transports.WebSocket?

That might be it. Unable to look at moment. ^.^;

The entire ‘socket’ system in Phoenix is pluggable, you could even design a new one that, oh, goes over SCTP or some proprietary protocol or whatever you want. In this case a simple edit to the websocket to handle it differently. It just comes with WebSocket and LongPolling as transports by default (which you choose in your socket setup file via transport).