↓ Ir para o conteúdo principal

← todas as notas

📎 Webclip

Phoenix & WebSockets

The discussion centers on raw WebSockets in Phoenix. Jakub says he needs direct access to the WebSocket, not Channels, and that Plug has no WebSocket API either. Chris McCord replies that Phoenix cannot support raw WebSockets directly yet, because its websocket support for Channels uses a private Cowboy API, and that the best option is a raw Cowboy websocket handler with Plug dispatch options.

Reading notes
#

  • Jakub needs raw WebSockets, not Channels, for a system he is building.
  • He is already using Cowboy for WebSockets and wants a small API in Phoenix for other requests.
  • He says Phoenix docs do not mention WebSockets.
  • He says Plug also has no WebSocket API.
  • He notes Phoenix runs on top of Cowboy, so he is currently running one Cowboy instance for WebSockets and another for Phoenix.
  • Steve Domin points to Phoenix websocket code in phoenix/endpoint/cowboy_websocket.ex.
  • Chris McCord says Phoenix cannot support raw WebSockets directly until Plug has a WebSocket API.
  • Chris says Phoenix supports websocket transport for Channels through a private API coupled to Cowboy.
  • Chris recommends Plug dispatch options and a raw Cowboy websocket handler for raw WebSockets.
  • Chris explains that Channels abstract the transport layer, support websockets and longpolling, and add pubsub and channel callbacks on top of the transport.
  • Chris says Channels also provide reconnects, backoff, error handling, authorization, and multiplexing over a single connection.
  • Ivan Miranda asks for the difference between Channels and WebSockets and thanks Chris for the clarification.
  • Josh Adams says he is working on a websockets proxy and would like to see common abstractions overlap.