fix(llc): ensure reconnection is automatic

This commit is contained in:
Salvatore Giordano
2022-03-15 15:56:26 +01:00
parent f301a467ba
commit 56b3506da3
2 changed files with 6 additions and 2 deletions
@@ -374,7 +374,6 @@ class StreamChatClient {
final event = await _ws.connect(user);
return user.merge(event.me);
} catch (e, stk) {
_wsConnectionStatus = ConnectionStatus.disconnected;
logger.severe('error connecting ws', e, stk);
rethrow;
}
@@ -112,6 +112,7 @@ class WebSocket with TimerHelper {
if (_webSocketChannel != null) {
_closeWebSocketChannel();
}
// throw Error();
_webSocketChannel =
webSocketChannelProvider?.call(uri) ?? WebSocketChannel.connect(uri);
_subscribeToWebSocketChannel();
@@ -220,7 +221,11 @@ class WebSocket with TimerHelper {
Duration(milliseconds: delay),
() async {
final uri = await _buildUri(refreshToken: refreshToken);
_initWebSocketChannel(uri);
try {
_initWebSocketChannel(uri);
} catch (e, stk) {
_onConnectionError(e, stk);
}
},
);
}