How to implement custom socket transport that uses long polling in Phoenix?

Hello! Can anyone help with making my own Socket adapter? there’s literally zero articles and projects on github doing this. I literally have no idea how would i implement custom long polling adapter, and how do i communicate with the adapter from outside, not using the phoenixjs library.

I’ve seen Phoenix.Socket.Transport but docs are basically saying to go look elsewhere, any help?

Phoenix already has a long polling socket transport, have you looked at its code?

By default long polling support in Phoenix channels should be enabled at least according to this documentation https://hexdocs.pm/phoenix/Phoenix.Socket.html

Why do you even need long polling? I think all browsers support websockets.

I still need to implement long polling according to already existing communication protocol, i cant just make the clients use phoenix libraries on their ends. So im looking for a way to implement a long polling adapter in phoenix with custom communication protocol.

Oh so not just any long polling but one with predetermined response format. Sorry can’t help you with that. Maybe look at Phoenix channels code see how it implements long polling and maybe you can just copy & paste & modify and create your own custom long polling transport.

Check out the cowboy_loop behaviour, you’re most likely going to have to drop down to that level.

https://ninenines.eu/docs/en/cowboy/2.7/manual/cowboy_loop/