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); final event = await _ws.connect(user);
return user.merge(event.me); return user.merge(event.me);
} catch (e, stk) { } catch (e, stk) {
_wsConnectionStatus = ConnectionStatus.disconnected;
logger.severe('error connecting ws', e, stk); logger.severe('error connecting ws', e, stk);
rethrow; rethrow;
} }
@@ -112,6 +112,7 @@ class WebSocket with TimerHelper {
if (_webSocketChannel != null) { if (_webSocketChannel != null) {
_closeWebSocketChannel(); _closeWebSocketChannel();
} }
// throw Error();
_webSocketChannel = _webSocketChannel =
webSocketChannelProvider?.call(uri) ?? WebSocketChannel.connect(uri); webSocketChannelProvider?.call(uri) ?? WebSocketChannel.connect(uri);
_subscribeToWebSocketChannel(); _subscribeToWebSocketChannel();
@@ -220,7 +221,11 @@ class WebSocket with TimerHelper {
Duration(milliseconds: delay), Duration(milliseconds: delay),
() async { () async {
final uri = await _buildUri(refreshToken: refreshToken); final uri = await _buildUri(refreshToken: refreshToken);
_initWebSocketChannel(uri); try {
_initWebSocketChannel(uri);
} catch (e, stk) {
_onConnectionError(e, stk);
}
}, },
); );
} }