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

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
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
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
psy-q
I’m trying to set up Emacs with elixir-ls via lsp-mode and credo via Flycheck. This should mostly be preconfigured as Flycheck picks up c...
New

Other Trending Topics Top

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
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
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
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
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

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews