fix(llc): make ws reconnection more robust

This commit is contained in:
Salvatore Giordano
2022-03-15 13:50:52 +01:00
parent 2d457de59d
commit da4c568cba
2 changed files with 7 additions and 2 deletions
@@ -374,6 +374,7 @@ 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;
} }
@@ -190,8 +190,12 @@ class WebSocket with TimerHelper {
_connectionStatus = ConnectionStatus.connecting; _connectionStatus = ConnectionStatus.connecting;
connectionCompleter = Completer<Event>(); connectionCompleter = Completer<Event>();
final uri = await _buildUri(); try {
_initWebSocketChannel(uri); final uri = await _buildUri();
_initWebSocketChannel(uri);
} catch (e, stk) {
_onConnectionError(e, stk);
}
return connectionCompleter!.future; return connectionCompleter!.future;
} }