You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This package will crash on line 127 in action_cable.dart:
final channelId = parseChannelId(payload['identifier']);
Because there is no identifier as we are not yet connected to a channel and a channel disconnect callback wouldn't be appropriate anyways since it's disconnecting the client.
We need to check if reason is 'unauthorized' and then call either onConnectionLost or onCannotConnect. I think onCannotConnect would be most appropriate, perhaps even passing the reconnect: false so we know not to retry the connection.
Let me know if you want to make this change or if I should just fork.
The text was updated successfully, but these errors were encountered:
Something as simple as this should work if you don't want to break current API, although it would be nice if we could pass retry, since I'm sure a lot of people have automatic connection retry handling on cannot connect.
case 'disconnect':
final identifier = payload['identifier'];
if (identifier != null) {
final channelId = parseChannelId(payload['identifier']);
final onDisconnected = _onChannelDisconnectedCallbacks[channelId];
if (onDisconnected != null) {
onDisconnected();
}
} else {
final reason = payload['reason'];
if (reason != null && reason == 'unauthorized') {
if (this.onCannotConnect != null) this.onCannotConnect!();
}
}
break;
I only allow authorized users to connect ActionCable, if the user is unauthorized I call reject_unauthorized_connection from Rails.
This sends a response
{
"type": "disconnect",
"reason": "unauthorized",
"reconnect": false
}
This package will crash on line 127 in action_cable.dart:
final channelId = parseChannelId(payload['identifier']);
Because there is no identifier as we are not yet connected to a channel and a channel disconnect callback wouldn't be appropriate anyways since it's disconnecting the client.
We need to check if reason is 'unauthorized' and then call either onConnectionLost or onCannotConnect. I think onCannotConnect would be most appropriate, perhaps even passing the reconnect: false so we know not to retry the connection.
Let me know if you want to make this change or if I should just fork.
The text was updated successfully, but these errors were encountered: