-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Consider a client connected only after receiving a welcome message. (#24
) * Fix a typo in action_cable_client (callaback vs callback). * Consider a client connected only after receiving a welcome message. Given an `action_cable_client` which: 1. connects to an action cable server 2. subscribes to the ChatChannel. 3. receives a message from that channel, then disconnect and starts the process from 1. at a certain point the client connects, but doesn't receive the subscription confirmation and therefore misses broadcast messages. A full example repository is available here: https://github.com/wpp/action-cable-debugging Turns out ActionCable expects a client not to send any messages (including subscription messages) before receiving a "welcome". Quoting from an issue I mistakenly opened on the rails project: > client must consider a connection to be ready/open only after > receiving "welcome" message (and not WebSocket OPEN event). Thus you > should not send any message before that. Sending messages after > receiving "welcome" from server guarantees that the socket is OPEN > (from the server point of view). > Hence the client doesn't implement Action Cable protocol correctly. > Take a look, for example, at Action Cable js client to see how it > should be implemented. If you have a look at the ActionCable JS client mentioned: https://github.com/rails/rails/blob/master/actioncable/app/assets/javascripts/action_cable/connection.coffee#L90 you can confirm that's what they are doing.
- Loading branch information
1 parent
0c53748
commit 695ca50
Showing
3 changed files
with
24 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters