silviurosu

silviurosu OP

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:

First 2 of 2 Posts Switch mode

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

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
roeland
Kia ora, We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
rahultumpala
Hello, I have an Elixir backend that implements a custom protocol over TCP. I want to load test the backend and assess the performance o...
New

Other Trending Topics Top

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
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge &amp; Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
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

We're in Beta

About us Mission Statement