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
13
votes
1 answer

Elixir + Phoenix Channels memory consumption

I'm pretty new to the Elixir and Phoenix Framework, so may be my question is a little bit dumb. I have an app with Elixir + Phoenix Framework as a backend and Angular 2 as a frontend. I am using Phoenix Channels as a channel for front-end/back-end…
heathen
  • 190
  • 2
  • 11
7
votes
1 answer

Phoenix Channels [warn] Ignoring unmatched topic "topic:subtopic" - How to Avoid Terminal Warning Message?

While running the Phoenix Chat Example App on localhost we are seeing this "noisy" warning: [warn] Ignoring unmatched topic "topic:subtopic" in ChatWeb.UserSocket code/phoenix-chat-example $ mix phx.server [info] Running ChatWeb.Endpoint with…
nelsonic
  • 31,111
  • 21
  • 89
  • 120
7
votes
3 answers

Phoenix Channels - Multiple channels per socket

I'm writing an application using Elixir Channels to handle realtime events. I understand that there will be 1 socket open per client and can multiplex multiple channels over it. So my app is a chat application where users are part of multiple group…
ed1t
  • 8,719
  • 17
  • 67
  • 110
7
votes
3 answers

How to clear a mailbox in channelcase phoenix framework test

I am doing a channel test that is receiving lots of messages. I may receive a message during setup, adjust some state and then I want to assert ( or refute ) another copy of that message was sent. I think I could do this by clearing the mailbox…
crododile
  • 145
  • 12
5
votes
1 answer

Heroku H15 errors with Elixir/Phoenix Channels

Once I started using Channels with Phoenix, I started getting a lot of these errors on Heroku: heroku[router]: at=error code=H15 desc="Idle connection" method=GET path="/socket/websocket?guardian_token=eyJhbGciOiJIUz[...]&vsn=1.0.0"…
Svilen
  • 2,608
  • 24
  • 26
5
votes
1 answer

Where to store socket connection in react-redux?

Tried two ways: call connectToServer() from action creator within Starter component in componentDidMount(); and dispatch like this: let socket = new Socket('ws://address/socket'); socket.connect(); dispatch({ type:…
mike00
  • 438
  • 1
  • 6
  • 17
4
votes
2 answers

How to test handle_info/2 in Phoenix LiveView?

Greetings Phoenix LiveView Wizards! Context We have a basic LiveView counter app: https://github.com/dwyl/phoenix-liveview-counter-tutorial The code is very simple: /live/counter.ex The App works as expected, see:…
4
votes
1 answer

Phoenix Presence: iterate through connected users in response to an event?

Suppose I have a Phoenix app that includes a realtime dashboard of data. I have a channel called MyApp.DashboardChannel, with a single topic of dashboard. In MyApp.DashboardChannel, I have a function like: def send_update do …
Nathan Long
  • 122,748
  • 97
  • 336
  • 451
4
votes
2 answers

Broadcast to different channel Phoenix 1.1.6

I'm trying to broadcast to a different channel in my app but I can not get it to work. Also I trying to write a test but I'm not sure how. From what I can gather I succeed in broadcasting the message from the notification_channel but it's not…
Note89
  • 251
  • 1
  • 9
4
votes
1 answer

Phoenix - return Ecto query results to a specific client

I'm currently trying to devise a scheme where the following happens. Client A is subscribed/connected to topic/channel T. A sends a message in the form of a select query to T. Only A receives the query results, no other subscribers. Is this even…
category
  • 2,113
  • 2
  • 22
  • 46
3
votes
1 answer

how to send message to different user in phoenix framework chat app

I am working with phoenix framework to create different type chat app. In my case, we have chat rooms but not functioning as a normal chat room. Every user has his own room he can join to his room using different devices (mobile, pc, some other…
user3172858
  • 91
  • 1
  • 10
3
votes
1 answer

When to use {:noreply, socket} vs {:reply, :ok, socket} in a Phoenix Channel?

I'm building a Javascript client app that has live communication with a Phoenix server, and wants to know if a message pushed to the server has been received. It looks like Phoenix's socket.js wants me to use something…
you786
  • 3,659
  • 5
  • 48
  • 74
3
votes
0 answers

Phoenix won't match topic to channel

I'm currently writing an instant messaging server on Phoenix version 1.2.1 and Elixir 1.4.1 and running into an issue involving channels. I started the project with --no-html and --no-brunch if that affects anything. when I attempt to send this…
Matt R
  • 39
  • 1
  • 4
3
votes
0 answers

Send a template partial as a message on phoenix channels

Is this a bad idea to send a partial template using channels? The other option is to send a JSON and have a duplicate template on javascript and eex. I’m asking this because I don’t know the channels internals and it may have a message size limit or…
2
votes
2 answers

Subscribe to Phoenix Channel on the backend (not channel.join())

Is it possible to subscribe the socket to some Phoenix channels on the backend and not from the client? Let's say I have some groups to which user belongs, and I want user to connect to them once WS connection is established. Sending ids of groups…
Ivan Yurov
  • 1,578
  • 10
  • 27
1
2 3 4 5 6 7