-
Notifications
You must be signed in to change notification settings - Fork 346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
StreamChatNetworkError(code: 1000, message: Unauthorised, token not defined) after rebuild of StreamChat widget #1841
Comments
Hi @flodaniel , why do you use the |
The stream here is a custom stream in my app, that I used to resolve issues when a user logged out and a new user logged in. When that happens I create a new StreamChatClient and this stream emits the new client. |
I can reproduce a crash on To disconnect: Future<void> logout() async {
try {
await _tokenRefreshListener?.cancel();
await _badgeListener?.cancel();
final token = await _getDeviceToken();
if (token != null) {
try {
await client.removeDevice(token);
} catch (_) {}
}
await client.disconnectUser(flushChatPersistence: true);
} catch (error, stackTrace) {
unawaited(SentryService().recordError(error, stackTrace: stackTrace));
} finally {
_initialized = null;
}
} To connect: Future<OwnUser> _connectUser() async {
final paveUser = _userRepository.user;
final streamUsername =
StreamChatHelper.convertUsernameToStreamUsername(paveUser.username);
final streamChatUser = User(
id: streamUsername,
name: paveUser.displayName,
image: paveUser.username,
);
final tokens = await _authenticationRepository.tokens();
final streamChatToken = tokens.streamChatToken;
return await client.connectUser(
streamChatUser,
streamChatToken,
);
} Worth to note that the Edit: |
Thank you for the clarification @flodaniel , I have yet another question, do you use a different |
We don't. |
Hey @flodaniel, we generally expect the widget to be recreated when the user changes. We can take a look into keeping the same widget for multiple users once we have more capacity on the team. Is this still an issue on your end? |
Which packages are you using?
stream_chat_flutter, stream_chat_persistance, stream_chat_localizations
On what platforms did you experience the issue?
iOS, Android
What version are you using?
stream_chat_flutter: 8.0.0-beta.2
stream_chat_localizations: 8.0.0-beta.2
stream_chat_persistence: 8.0.0-beta.2
What happened?
I have the below code to manage updates to my client (e.g. user logs out and logs in with a different account). If stream emits for the same user again it seems to create a new instance as i then get
StreamChatNetworkError(code: 1000, message: Unauthorised, token not defined)
when calling.watch
on a channel:Steps to reproduce
Supporting info to reproduce
No response
Relevant log output
No response
Flutter analyze output
No response
Flutter doctor output
Code of Conduct
The text was updated successfully, but these errors were encountered: