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
//
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.
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
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...')
);
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








