@@ -337,6 +337,7 @@ export function connectWebAPIService(webAPIServiceURL: string): ThunkAction {
337
337
} ;
338
338
339
339
let keepAliveTimer = null ;
340
+ const keepAliveSeconds = 5 ;
340
341
341
342
webAPIClient . onOpen = ( ) => {
342
343
dispatch ( setWebAPIClient ( webAPIClient ) ) ;
@@ -345,10 +346,10 @@ export function connectWebAPIService(webAPIServiceURL: string): ThunkAction {
345
346
dispatch ( loadPreferences ( ) ) ;
346
347
dispatch ( loadDataStores ( ) ) ;
347
348
dispatch ( loadOperations ( ) ) ;
348
- keepAliveTimer = setInterval ( keepAlive , 2500 ) ;
349
+ keepAliveTimer = setInterval ( keepAlive , keepAliveSeconds * 1000 ) ;
349
350
} ;
350
351
351
- webAPIClient . onClose = ( event ) => {
352
+ webAPIClient . onClose = ( event : CloseEvent ) => {
352
353
if ( keepAliveTimer !== null ) {
353
354
clearInterval ( keepAliveTimer ) ;
354
355
}
@@ -359,19 +360,36 @@ export function connectWebAPIService(webAPIServiceURL: string): ThunkAction {
359
360
}
360
361
// When we end up here, the connection closed unintentionally.
361
362
console . error ( 'webAPIClient.onClose:' , event ) ;
363
+ const closeDetails = `reason=${ event . reason } , code=${ event . code } , clean=${ event . wasClean } ` ;
364
+ showToast (
365
+ {
366
+ type : 'notification' ,
367
+ text : formatMessage ( `Connection to Cate service closed: ${ closeDetails } ` , event )
368
+ } ,
369
+ 120 * 1000
370
+ ) ;
362
371
dispatch ( setWebAPIStatus ( 'closed' ) ) ;
363
- showToast ( { type : 'notification' , text : formatMessage ( 'Connection to Cate service closed' , event ) } ) ;
364
372
} ;
365
373
366
- webAPIClient . onError = ( event ) => {
374
+ webAPIClient . onError = ( event : ErrorEvent ) => {
367
375
console . error ( 'webAPIClient.onError:' , event ) ;
368
376
dispatch ( setWebAPIStatus ( 'error' ) ) ;
369
- showToast ( { type : 'error' , text : formatMessage ( 'Error connecting to Cate service' , event ) } ) ;
377
+ showToast (
378
+ {
379
+ type : 'error' ,
380
+ text : formatMessage ( 'Error connecting to Cate service' , event )
381
+ }
382
+ ) ;
370
383
} ;
371
384
372
- webAPIClient . onWarning = ( event ) => {
385
+ webAPIClient . onWarning = ( event : Event ) => {
373
386
console . warn ( 'webAPIClient.onWarning:' , event ) ;
374
- showToast ( { type : 'warning' , text : formatMessage ( 'Warning from Cate service' , event ) } ) ;
387
+ showToast (
388
+ {
389
+ type : 'warning' ,
390
+ text : formatMessage ( 'Warning from Cate service' , event )
391
+ }
392
+ ) ;
375
393
} ;
376
394
} ;
377
395
}
0 commit comments