katehedgpeth
I am trying upgrade to Elixir 1.8, Erlang 21, and Phoenix 1.4. I’m getting an error with our custom http dispatch config, which was added when we were at Phoenix 1.3/Elixir 1.5.
Here is our config:
config :site, SiteWeb.Endpoint,
http: [
dispatch: [
{:_,
[
{"/socket/websocket", Phoenix.Endpoint.CowboyWebSocket,
{Phoenix.Transports.WebSocket, {SiteWeb.Endpoint, SiteWeb.UserSocket, :websocket}}},
{"/socket/longpoll", Plug.Cowboy.Handler,
{Phoenix.Transports.LongPoll, {SiteWeb.Endpoint, SiteWeb.UserSocket, :longpoll}}},
{:_, Plug.Cowboy.Handler, {SiteWeb.Endpoint, []}}
]}
]
]
And the error we’re seeing:
** (UndefinedFunctionError) function Phoenix.Endpoint.CowboyWebSocket.init/2 is undefined or private
(phoenix) Phoenix.Endpoint.CowboyWebSocket.init(%{bindings: %{}, body_length: 0, cert: :undefined, has_body: false, headers: %{"accept-encoding" => "gzip, deflate, br", "accept-language" => "en-US,en;q=0.9", "cache-control" => "no-cache", "connection" => "upgrade", "cookie" => "_ga=GA1.2.323690242.1505750053; __insp_uid=4076678333; _ga=GA1.3.1382101712.1505318427; fs_uid=fullstory.com`AQKVD`5182813288529920:5629499534213120; __insp_wid=101978311; __insp_nv=false; __insp_targlpu=aHR0cHM6Ly9kZXYubWJ0YWNlLmNvbS8%3D; __insp_targlpt=TUJUQSAtIE1hc3NhY2h1c2V0dHMgQmF5IFRyYW5zcG9ydGF0aW9uIEF1dGhvcml0eQ%3D%3D; __insp_norec_sess=true; __insp_slim=1525973426869; mbta_id=32820746; _ga=GA1.4.323690242.1505750053; _site_key=SFMyNTY.g3QAAAAA.xxxBgGh7d8xGoy6cezO2La-1xvwRbt_RjIPutJlQj8U; _gid=GA1.3.930802726.1551714745; _gid=GA1.2.930802726.1551714745; mbta_visited_routes=CR-Fitchburg|85; _gid=GA1.4.930802726.1551714745; _gat_UA-82280837-1=1", "host" => "green.dev.mbtace.com", "origin" => "https://green.dev.mbtace.com", "pragma" => "no-cache", "sec-websocket-extensions" => "permessage-deflate; client_max_window_bits", "sec-websocket-key" => "IdIkX8mVrmEKVbPIdL0ZZw==", "sec-websocket-version" => "13", "upgrade" => "websocket", "user-agent" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36", "x-amzn-trace-id" => "Root=1-5c7eece1-4c47339fb70d03ccbdd1d686", "x-forwarded-for" => "67.208.190.2, 67.208.190.2", "x-forwarded-port" => "443", "x-forwarded-proto" => "https", "x-real-ip" => "67.208.190.2"}, host: "green.dev.mbtace.com", host_info: :undefined, method: "GET", path: "/socket/websocket", path_info: :undefined, peer: {{172, 17, 0, 1}, 54138}, pid: #PID<0.6326.0>, port: 80, qs: "vsn=2.0.0", ref: SiteWeb.Endpoint.HTTP, scheme: "http", sock: {{172, 17, 0, 2}, 4000}, streamid: 9, version: :"HTTP/1.1"}, {Phoenix.Transports.WebSocket, {SiteWeb.Endpoint, SiteWeb.UserSocket, :websocket}})
(cowboy) /root/deps/cowboy/src/cowboy_handler.erl:41: :cowboy_handler.execute/2
(cowboy) /root/deps/cowboy/src/cowboy_stream_h.erl:296: :cowboy_stream_h.execute/3
(cowboy) /root/deps/cowboy/src/cowboy_stream_h.erl:274: :cowboy_stream_h.request_process/3
(stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Initial Call: :cowboy_stream_h.request_process/3
Ancestors: [#PID<0.6326.0>, #PID<0.2391.0>, #PID<0.2390.0>, SiteWeb.Endpoint, Site.Supervisor, #PID<0.2377.0>]
As far as I can tell, Phoenix.Endpoint.CowboyWebSocket hasn’t changed in a while, so I’m guessing that there was some change to how the args are being passed to that init function? I’m struggling to follow the pipeline to even figure out how this is getting called. If anyone has any suggestions they would be greatly appreciated!
Trending in Questions
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
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
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
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
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New
Other Trending Topics
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
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
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
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
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
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #elixirconf-eu
- #metaprogramming
- #hex










Most Liked- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
katehedgpeth
After combing through the commits in the socket transport refactor in Phoenix 1.4 much more carefully, I believe I have solved my problem – I thought i would document it here in case anyone else comes across this same issue.
With the new socket transport, sockets do not appear to need their own dispatch transports; Phoenix.Endpoint.Cowboy2Handlers takes care of everything. So I was able to replace the above config with simply:
blatyo
I think you’re just using an old adapter.
Phoenix.Endpoint.CowboyWebSocketappears to be for cowboy 1. If you upgraded to cowboy 2, I think you want to follow this: Phoenix.Endpoint.Cowboy2Adapter — Phoenix v1.8.8