kartheek

kartheek

Phoenix Channel - "unmatched topic" error and retries

TLDR: In case of “unmatched topic” error, phoenix.js library continuously retries to rejoin the channel. Shouldn’t the default retry behaviour for “unmatched topic” error - be stop further rejoin attempts or try to join n times?

When a topic does not match any topic defined in channels, server returns the “unmatched topic” error.

[null,“6”,“topic:subtopic”,“phx_reply”,{“response”:{“reason”:“unmatched topic”},“status”:“error”}]

Phoenix 1.5.8 branch

https://github.com/phoenixframework/phoenix/blob/4e066449cce05a866ca2d181ce1ec6bbbfc32537/assets/js/phoenix.js#L400

// 
 this.joinPush.receive("error", () => {
      this.state = CHANNEL_STATES.errored
      if(this.socket.isConnected()){ this.rejoinTimer.scheduleTimeout() }
    })

The channel state is set to errored, but in the next line scheduleTimeout() is called which schedules a rejoin on next timeout.

https://github.com/phoenixframework/phoenix/blob/4e066449cce05a866ca2d181ce1ec6bbbfc32537/assets/js/phoenix.js#L621

rejoin(timeout = this.timeout){ if(this.isLeaving()){ return }
    this.socket.leaveOpenTopic(this.topic)
    this.state = CHANNEL_STATES.joining
    this.joinPush.resend(timeout)
  }

Rejoin just clears out error state and results in an endless loop of rejoin in case of “unmatched topic”

  • When channel state is set to error - it is not checked in rejoin function - should it be checked?
  • When a “unmatched topic” happens - default behaviour should be to try n times and stop or infinitely try to connect back to server?

What am I missing in this scenario ?

Edited: grammar and typos

Most Liked

nichita-pasecinic

nichita-pasecinic

just leave the channel after join returned an error

channel
        .join()
        .receive('ok', (response) => console.log('catching up', response))
        .receive('error', (response) => {
          console.log('failed join', response);
          channel.leave();
        })
        .receive('timeout', () =>
          console.log('Networking issue. Still waiting...')
        );

Where Next?

Popular in Questions Top

lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
earth10
Hi, I’m just starting to build a side-project with Elixir and Phoenix and doing some basic test with Elixir alone. What strikes me is th...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> somethi...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
yawaramin
In the Dialyzer docs ( dialyzer — OTP 29.0.2 (dialyzer 6.0.1) ), there is a way to turn off a specific warning for a function: -dialyzer...
New

Other popular topics Top

chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
Nvim
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help. Where are they similar? Where do they differ the m...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Latest on Elixir Forum

We're in Beta

About us Mission Statement