Binary pushes don't work over the LongPoll transport

Abierto
#6,906 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@mandar1045 ya está trabajando en esto.

Desde el 14/11/2026.

  • #6907 de @mandar1045 — abierto

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
elixir, javascript
Área
backend

Línea de trabajo

Start with Phoenix.Transports.LongPoll.Server, where the {:push, ...} and {:reply, ...} clauses drop the frame opcode before buffering, and with the LongPoll client path in longpoll.js that parses the messages list. Run the LongPoll transport tests and add a case that pushes {:binary, <<255,1,2>>} then another message, checking the poll returns both without a 500 and the client parses them. Done means binary server-to-client frames round-trip over LongPoll as they do over WebSocket; note #6907 already proposes a base64 approach, so review it first.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Pushing binary data from a channel doesn't work when the client is on the LongPoll transport.

def handle_info(:send_bin, socket) do
  push(socket, "bin", {:binary, <<255, 1, 2>>})
  {:noreply, socket}
end

Over WebSocket this works fine. Over LongPoll:

  • if the data is not valid UTF-8, the poll request fails with a 500 ({:invalid_byte, 255} from the JSON encoder), and since the server already cleared its buffer, every other buffered message in that poll is lost too (including the join reply in my test)
  • if the data happens to be valid UTF-8, the raw binary frame ends up as a string in the messages list, e.g. "\u0000\u0001\u0006\u00031room:xbinhello", and phoenix.js fails trying to JSON.parse it

Looks like Phoenix.Transports.LongPoll.Server drops the opcode ({:push, {_, reply}, state} / {:reply, status, {_, reply}, state}) and buffers the binary as if it was text. Client to server binary over LongPoll is already handled (base64 encoded, from #5513), but the server to client direction isn't.

One option would be to base64 encode binary frames on the server like the upload path does, and have longpoll.js decode them before handing them to the socket.

Lenguaje dominante
Elixir
Estrellas
23.2k
Forks
3.2k
Merge medio
16 h 35 min
PR fusionados (30 d)
18

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de phoenixframework/phoenix

Todos los issues de phoenixframework/phoenix

Issues similares

Más issues de Elixir

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.