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:

Showing Posts 1 to 2

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.

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?

— All posts loaded —

Where Next? Top

Trending in Questions Top

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
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
achenet
Hello, I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind. However, when I launch mix phx.server, I get an error...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
mnkhod
So i have been using ash framework for a while and i love it. However currently the issue im having with ash framework is the error handl...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
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

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews