silviurosu

silviurosu

I can not figure out how to make phoenix sockets longpool work. My config is like this:
in endpoint.ex:

socket("/socket", Carts.ApiWeb.CartSocket, websocket: true, longpoll: true)

in cart_socket.ex:

channel("cart:*", Carts.ApiWeb.CartChannel)

in config:

config :carts_api, Carts.ApiWeb.Endpoint,
  http: [port: "${CARTS_PORT}", protocol_options: [max_keepalive: 200]],
  url: [host: "${CARTS_URL}", port: 443, scheme: "https"],
  secret_key_base: "${SECRET_KEY_BASE}",
  check_origin: false

And I keep being bombarded with this error on server side side:

Elixir.ErlangError · Erlang error: {{%Phoenix.Router.NoRouteError{conn: %Plug.Conn{adapter: {Plug.Cowboy.Conn, :…}, assigns: %{}, before_send: [function<0.44602488/1 in Carts.ApiWeb.PipelineInstrumenter.call/2>, function<1.112466771/1 in Plug.Logger.call/2>], body_params: %{}, cookies: %Plug.Conn.Unfetched{aspect: :cookies}, halted: false, host: “.zuppler.com", method: “GET”, owner: pid<0.6594.29>, params: %{“vsn” => “2.0.0”}, path_info: [“socket”, “longpoll”], path_params: %{}, port: 80, private: %{Carts.ApiWeb.Router => {[], %{Zuppler.Phoenix.Utils.PingPongPlugRouter => [“ping”]}}, :phoenix_endpoint => Carts.ApiWeb.Endpoint, :phoenix_router => Carts.ApiWeb.Router, :plug_session_fetch => function<1.64872641/1 in Plug.Session.fetch_session/1>}, query_params: %{“vsn” => “2.0.0”}, query_string: “vsn=2.0.0&”, remote_ip: {192, 168, 126, 248}, req_cookies: %Plug.Conn.Unfetched{aspect: :cookies}, req_headers: [{“accept”, "/"}, {“accept-encoding”, “gzip, deflate, peerdist”}, {“accept-language”, “en-US”}, {“cache-control”, “no-cache”}, {“content-type”, “application/json”}, {“dnt”, “1”}, {“host”, ".zuppler.com"}, {“origin”, “https://www.cuginisyracuse.com”}, {“referer”, “https://www.cuginisyracuse.com/”}, {“ua-cpu”, “AMD64”}, {“user-agent”, “Mozilla/5.0 (Windows NT 6.1; Win64; x64; Trident/7.0; rv:11.0) like Gecko”}, {“x-forwarded-for”, “65.196.116.115”}, {“x-forwarded-host”, ".zuppler.com"}, {“x-forwarded-port”, “443”}, {“x-forwarded-proto”, “https”}, {“x-original-uri”, “/socket/longpoll?vsn=2.0.0&”}, {“x-p2p-peerdist”, “Version=1.0”}, {“x-real-ip”, “65.196.116.115”}, {“x-request-id”, “2c83b337fe13a6b236963044ebe5a213”}, {“x-scheme”, “https”}], request_path: “/socket/longpoll”, resp_body: nil, resp_cookies: %{}, resp_headers: [{“cache-control”, “max-age=0, private, must-revalidate”}, {“x-request-id”, “2c83b337fe13a6b236963044ebe5a213”}, {“vary”, “Origin”}, {“access-control-allow-origin”, “https://www.cuginisyracuse.com”}, {“access-control-expose-headers”, “”}, {“access-control-allow-credentials”, “true”}], scheme: :http, script_name: [], secret_key_base: :…, state: :unset, status: nil}, message: “no route found for GET /socket/longpoll (Carts.ApiWeb.Router)”, plug_status: 404, router: Carts.ApiWeb.Router}, [{Carts.ApiWeb.Router, :“call (overridable 2)”, 2, [file: ‘lib/phoenix/router.ex’, line: 324]}, {Carts.ApiWeb.Router, :call, 2, [file: ‘lib/plug/error_handler.ex’, line: 64]}, {Carts.ApiWeb.Endpoint, :plug_builder_call, 2, [file: ‘lib/carts-api-web/endpoint.ex’, line: 1]}, {Carts.ApiWeb.Endpoint, :call, 2, [file: ‘lib/carts-api-web/endpoint.ex’, line: 1]}, {Plug.Cowboy.Handler, :init, 2, [file: ‘lib/plug/cowboy/handler.ex’, line: 12]}, {:cowboy_handler, :execute, 2, [file: ‘/tmp/build/deps/cowboy/src/cowboy_handler.erl’, line: 41]}, {:cowboy_stream_h, :execute, 3, [file: ‘/tmp/build/deps/cowboy/src/cowboy_stream_h.erl’, line: 296]}, {:cowboy_stream_h, :request_process, 3, [file: ‘/tmp/build/deps/cowboy/src/cowboy_stream_h.erl’, line: 274]}]}, {MasterProxy.Plug, :call, [%Plug.Conn{adapter: {Plug.Cowboy.Conn, :…}, assigns: %{}, before_send: [], body_params: %Plug.Conn.Unfetched{aspect: :body_params}, cookies: %Plug.Conn.Unfetched{aspect: :cookies}, halted: false, host: ".zuppler.com", method: “GET”, owner: pid<0.6594.29>, params: %Plug.Conn.Unfetched{aspect: :params}, path_info: [“socket”, “longpoll”], path_params: %{}, port: 80, private: %{}, query_params: %Plug.Conn.Unfetched{aspect: :query_params}, query_string: “vsn=2.0.0&”, remote_ip: {192, 168, 126, 248}, req_cookies: %Plug.Conn.Unfetched{aspect: :cookies}, req_headers: [{“accept”, "/”}, {“accept-encoding”, “gzip, deflate, peerdist”}, {“accept-language”, “en-US”}, {“cache-control”, “no-cache”}, {“content-type”, “application/json”}, {“dnt”, “1”}, {“host”, “*.zuppler.com"}, {“origin”, “https://www.cuginisyracuse.com”}, {“referer”, “https://www.cuginisyracuse.com/”}, {“ua-cpu”, “AMD64”}, {“user-agent”, “Mozilla/5.0 (Windows NT 6.1; Win64; x64; Trident/7.0; rv:11.0) like Gecko”}, {“x-forwarded-for”, “65.196.116.115”}, {“x-forwarded-host”, ".zuppler.com”}, {“x-forwarded-port”, “443”}, {“x-forwarded-proto”, “https”}, {“x-original-uri”, “/socket/longpoll?vsn=2.0.0&”}, {“x-p2p-peerdist”, “Version=1.0”}, {“x-real-ip”, “65.196.116.115”}, {“x-request-id”, “2c83b337fe13a6b236963044ebe5a213”}, {“x-scheme”, “https”}], request_path: “/socket/longpoll”, resp_body: nil, resp_cookies: %{}, resp_headers: [{“cache-control”, “max-age=0, private, must-revalidate”}], scheme: :http, script_name: , secret_key_base: nil, state: :unset, status: nil}, ]}}

I have no idea how to fix this :frowning_face:

Most Liked

sneako

sneako

Check out this recent issue on Phoenix’s github: Fallback to LongPoll not working on iOS · Issue #2914 · phoenixframework/phoenix · GitHub

Chris’s code example may provide some useful hints.

And perhaps you should post your javascript as well.

Last Post!

silviurosu

silviurosu OP

I will try to extract the js code from the SPA application, I have not written that.
But looking inside this crash it shows that the client tries to connect to longpool url: “/socket/longpoll?vsn=2.0.0&”
This is why I presume it may be a server side issue.
Should this route be automatically added by Phoenix or there is something I need to do?

Where Next? Top

Trending in Questions Top

water
I’m aware of 2 such projects, are there others? git: GitHub - team-alembic/realworld: A fullstack Phoenix LiveView application with back...
New
katta
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
peck
Hi everyone. My team and I have been working on a fairly modest app based around video streaming and chat, but we’ve landed a customer t...
New
bradley
I really like the adapter patterns that ecto, nebulex, waffle, etc. use and would love find something similar for a key management servic...
New
unaware8150
Hello folks! So at work, we are seeing some situations where we have to define some “fixed” strings that are used across the codebase in...
New
Alvinkariuki
How Can I Optimise Compile Time Dependencies I have been building an elixir application for about 2 years now. Many modules and files ha...
New
leoschweizer
Hi, we run different LLM models across a cluster, with each node loading a configurable subset. Model-specific queues let nodes consume ...
New

Other Trending Topics Top

budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
budgie
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with. But I don’t use it anymore. Serverless was the promis...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews