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

How to get channel messages in Elixir Phoenix to change the state of a React component?

I'm trying to figure out how to get the state of a component to update based on an external event, and in this case the external event is a message coming down an Elixir Phoenix channel. So basically, I have a simple h1 tag and it must always…
Thomas Browne
  • 23,824
  • 32
  • 78
  • 121
1
vote
1 answer

How to read new Phoenix channel instance's state in Channel test case?

I have the following phoenix channel that handle an incoming message, broadcasts it and then updates the channel instance's socket state: defmodule MyApp.MyChannel do use MyApp.Web, :channel def join("topic", _payload, socket) do {:ok,…
1
vote
1 answer

How does topic count affect channels performance in the Phoenix framework?

I am currently creating an application with the Phoenix framework that uses channels for two way communication between a large number of mobile devices and a back-end service (obviously Phoenix based). I am intending to create a single topic for…
Chedy2149
  • 2,821
  • 4
  • 33
  • 56
1
vote
0 answers

Phoenix channel.push not working on Android

I am trying to have chat in my application using Phoenix channels. I have a web client and and an Android client. Right now it is working correctly on the web. I am having an issue with the Android side. It is able to receive messages pushed to…
1
vote
1 answer

Architecture/Technical Challenges in Handling Authentication/Permissions in Elixir Channels/Sockets

So I have decided to rewrite an application I have been writing in Node.js to Elixir because of all the extra complexity working with Node that Elixir comes with out of the box. My issue was something I didn't have quite right in Node and is…
Morgan G
  • 3,089
  • 4
  • 18
  • 26
1
vote
1 answer

How to test or serialize struct in Phoenix.Socket.Broadcast payload?

How to automatically serialize ecto struct to json response in channel test? As I can see in documentation The event’s message must be a serializable map, I found in answer and in tutorial that when I use Poison.Encoder in model then any message…
luzny
  • 2,380
  • 7
  • 30
  • 64
1
vote
1 answer

Only authenticating some channels on join in Phoenix

How can I change this code to connect to a channel that doesn't require authentication, while still allowing authentication on some channels? phoenix.js:701 WebSocket connection to 'ws://localhost:4000/socket/websocket?token=&vsn=1.0.0' failed:…
humdinger
  • 521
  • 1
  • 3
  • 18
1
vote
0 answers

Is socket.assets safe in phoenix-framework?

Can client (for example Phoenix Channels JavaScript client) read or write data from socket.assigns? Does by default server sign or encrypt this data? To be more specific, here is fragment of server code: def join("rooms:example", _, socket) do …
1
vote
0 answers

Phoenix - connect socket, join channel, push, receive messages from ANOTHER application

For learning purposes I created this simple TODO app that uses Phoenix Channels instead of Controllers to CRUD lists and todos: https://chandothis.herokuapp.com/ and the code is here: https://github.com/iacobson/chan_do_this Now I want to continue…
iacobSon
  • 133
  • 10
1
vote
2 answers

JDBC Phoenix driver for HBASE, retries 36 and throws exception

I have a standalone HBase installed in a server(Remote). I written a Java Client, which communicates using Phoenix, and saw it tries for 36 attempts and hence throws exception. HBase-Version : 1.1.5 Phoenix-core:…
peaceUser
  • 457
  • 5
  • 19
1
vote
0 answers

Broadcast to all active channel - Phoenix framework Elixir

Simple question, is it possible to make a broadcast from controller to all active channel? For example here is my controller: # Controller defmodule Rumbl.DiscussionController do use Rumbl.Web, :controller def blast(conn, _params) do …
opan
  • 11
  • 1
  • 2
1
vote
1 answer

Error with link to: in deleting a session (PHOENIX)

I have a link to delete the session for the current user <%= link "Logout", to: session_path(@conn, :delete, current_user.id), method: :delete, class: "button alert" %> For some reason it doesn't work although when I changed the link to a button…
Robin Solanki
  • 203
  • 1
  • 8
1
vote
2 answers

How to detect current topic?

Where would I store topic id? As for socket, I can use: def join("topic:" <> topic_id, _params, socket) do ... socket= assign(socket, :topic_id, topic_id) {:ok, socket} end That was at socket scope, but my users can join multiple topics…
simo
  • 23,342
  • 38
  • 121
  • 218
0
votes
0 answers

Phoenix - Changes to socket.assigns not reflected in another channel under the same socket?

I probably have a wrong mental model of how sockets and channels work in Phoenix. This is the scenario that confuses me: I declare two channels under the same socket: defmodule MyAppWeb.TestSocket do channel("a:*", MyAppWeb.AChannel) …
xji
  • 7,341
  • 4
  • 40
  • 61
0
votes
0 answers

How can I create ad-hoc channels with Phoenix?

I'm looking at some tutorials to make a chat backend. In my case, I have users who will be creating their own rooms, plus rooms for specific topics that I will create. In a lot of the tutorials and documentation, one defines a channel like: channel…
user1354934
  • 8,139
  • 15
  • 50
  • 80