@@ -141,6 +141,7 @@ class HttpClientLink extends ClientLink {
141141 // https://github.com/dart-lang/sdk/issues/31275
142142 // When it is fixed, we should go back to a regular try-catch
143143 runZoned (() async {
144+ await ()async {
144145 HttpClientRequest request = await client.postUrl (connUri);
145146 Map requestJson = {
146147 'publicKey' : privateKey.publicKey.qBase64,
@@ -198,7 +199,10 @@ class HttpClientLink extends ClientLink {
198199 if (serverConfig['format' ] is String ) {
199200 format = serverConfig['format' ];
200201 }
201-
202+ }().timeout (new Duration (minutes: 1 ), onTimeout: (){
203+ _client.close (force: true );
204+ throw new Exception ('timeout' );
205+ });
202206 await initWebsocket (false );
203207 }, onError: (e, s) {
204208 logger.warning ("Client socket crashed: $e $s " );
@@ -227,14 +231,8 @@ class HttpClientLink extends ClientLink {
227231 wsUrl = '$wsUrl $tokenHash ' ;
228232 }
229233
230- var socket = await awaitWithTimeout (
231- HttpHelper .connectToWebSocket (wsUrl,
232- useStandardWebSocket: useStandardWebSocket),
233- // websocket initialization should take no more than 60 seconds
234- 60000 ,
235- (WebSocket socket){socket.close ();},
236- (err){}
237- );
234+ var socket = await HttpHelper .connectToWebSocket (wsUrl,
235+ useStandardWebSocket: useStandardWebSocket);
238236
239237 _wsConnection = new WebSocketConnection (
240238 socket,
0 commit comments