diff --git a/ui/src/message/WebSocketStore.ts b/ui/src/message/WebSocketStore.ts index 89501e8..f7747f2 100644 --- a/ui/src/message/WebSocketStore.ts +++ b/ui/src/message/WebSocketStore.ts @@ -1,6 +1,7 @@ import {SnackReporter} from '../snack/SnackManager'; import {CurrentUser} from '../CurrentUser'; import * as config from '../config'; +import {AxiosError} from 'axios'; export class WebSocketStore { private wsActive = false; @@ -32,10 +33,17 @@ export class WebSocketStore { ws.onclose = () => { this.wsActive = false; - this.currentUser.tryAuthenticate().then(() => { - this.snack('WebSocket connection closed, trying again in 30 seconds.'); - setTimeout(this.listen, 30000); - }); + this.currentUser + .tryAuthenticate() + .then(() => { + this.snack('WebSocket connection closed, trying again in 30 seconds.'); + setTimeout(this.listen, 30000); + }) + .catch((error: AxiosError) => { + if (error && error.response && error.response.status === 401) { + this.snack('Could not authenticate with client token, logging out.'); + } + }); }; this.ws = ws;