Questions tagged [phoenix-channels]

Phoenix framework's channels give the tools to organize the code and the communication among users while keeping the connection opened for live messages updates, its transportation-agnostic, so it can use different protocols, like websocket or log polling..

A Phoenix channel is a conversation. The channel sends messages, receives messages, and keeps state. We call the messages events, and we put the state in a struct called socket. A Phoenix conversation is about a topic, and it maps onto application concepts like a chat room, a local map, a game, or in our case, the annotations on a video. More than one user might be interested in the same topic at the same time. Channels give you tools to organize your code and the communication among users. The concept that makes channels so powerful in Elixir is that each user’s conversation on a topic has its own isolated, dedicated process.

102 questions
1
vote
0 answers

Elixir Phoenix application with Channels websockets not working on Google AppEngin

I tried to run an Elixir web app with Channels, but it didn't work on AppEngine Flex.I used this instructions: https://cloud.google.com/community/tutorials/elixir-phoenix-on-google-app-engine My app is very very simple, only a hello world websockets…
1
vote
2 answers

How can I get Phoenix to join channels automatically when a client connects?

I'm using websocket transport with Phoenix Channels, but I'm trying to provide a clean API for consumers without a Phoenix.Socket client to use with just websockets. For simplicity, I'd like to auto-subscribe users to various channels when they open…
cjm2671
  • 18,348
  • 31
  • 102
  • 161
1
vote
1 answer

Phoenix Channel can't maintain connection with frontend once the connection is established (Error during WebSocket handshake)

I have a problem with WebSocket connection. I use Phoenix as my API and Vue + phoenix-socket on the frontend. My browser console looks like this: receive: ok feed:1 phx_reply (1) {response: {…}, status: "ok"} Joined successfully {feed:…
1
vote
1 answer

How to keep my Android app connected to the backend channel to receive updates and trigger events in device?

I am working on an Android project where my app is connected to user_channel in background and shows a notification when a new event occurs in the channel. The Viewmodel code @RequiresApi(Build.VERSION_CODES.O) fun getNotifications(callback:…
1
vote
2 answers

Fix “owner #PID<…> exited with: shutdown” in tests for my terminate/2 method of Phoenix.Channel

Looking for a help with testing terminate/2 callback in my Channel. Test and setup looks like this: setup do :ok = Ecto.Adapters.SQL.Sandbox.checkout(MyApp.Repo) Ecto.Adapters.SQL.Sandbox.mode(MyApp.Repo, {:shared, self()}) {:ok, socket} =…
1
vote
2 answers

Handling websocket connection on invalid token in Elixir/Phoenix

We use Guardian to generate tokens, which we then use for authentication when connecting to Phoenix Channels' socket. Recently we found that some users never leave certain pages, and after a month or so, the token becomes invalid, which invalidates…
1
vote
2 answers

Phoenix 1.4 Upgrade - (FunctionClauseError) no function clause matching in Phoenix.Socket.__terminate__/2

I recently upgraded my Phoenix app from 1.3 to 1.4. Everything is great except that when I navigate away from a page I’m getting the following error: [error] GenServer #PID<0.509.0> terminating ** (FunctionClauseError) no function clause matching…
kevinstueber
  • 2,926
  • 3
  • 26
  • 26
1
vote
2 answers

Is there a way to get presences list inside a controller?

I'm trying to get the presences list inside a phoenix controller, but I need the socket to use the function Presence.list(socket). Anyone knows how to use Presence.list(socket) inside a controller? The reason why I am trying this is that I want to…
1
vote
0 answers

Is there any way to call controller method from phoenix channel to and fro

I need to call a function inside the controller from phoenix channel. This is my phoenix channel //dashboardChannel.ex def join("dashboard:lobby", payload, socket) do IO.puts "Entered Room" if authorized?(payload) do …
Jeeva
  • 1,550
  • 12
  • 15
1
vote
1 answer

Ignoring unmatched topic "heartbeat" in MyApplication.UserSocket

This problem seems so basic that I can absolutely not find any information about it in tutorials nor in documentation. Yet if my clients ping the "heartbeat" (both the iOS and Android clients use heartbeat by default) it's not working: [warn]…
Lucas van Dongen
  • 9,328
  • 7
  • 39
  • 60
1
vote
0 answers

Multiplayer game - Elixir channels

I'm beginner in Elixir. I have an elixir application for a multiplayer game that simply replicates the received command to all players connected to the channel. This is work but have some latency when replicates the received command. what is the…
Nuno_Coletiv
  • 367
  • 3
  • 16
1
vote
1 answer

Player 1 invites Player 2 to play a game with Phoenix Channels

I'm creating a card game in Phoenix with 2 players using Phoenix channels and GenServer. This is what my Game Struct looks like: schema "games" do field :winner, :integer field :player_1, :id, default: nil field :player_2, :id,…
1
vote
1 answer

Connect to Phoenix Socket with Token and Presence

I'm trying to tie together the Phoenix Channel, Token, and Presence modules to add chat functionality to my Phoenix 1.3 application. I haven't been able to get all 3 modules working together. The last error was connection to websocket closed before…
1
vote
1 answer

Connecting remote client to Phoenix channel

I'm trying to separate my front end from Phoenix 1.3 (localhost:4000) and I'm running a React on localhost:3000. I cannot for the life of me connect to Phoenix. I get the error: WebSocket connection to…
Ian
  • 544
  • 3
  • 16
1
vote
1 answer

Elixir/Phoenix Endpoint broadcast from another module

I have a channel, which does some things in back-end when you connect to it. I need to send response back, once the back-end job is completed. Here is my channel: def join("boot", _, socket) do Launcher.start() {:ok, socket} end def…
Ilya
  • 1,120
  • 1
  • 12
  • 33