mirror of
https://github.com/unraid/api.git
synced 2026-01-28 19:49:08 -06:00
fix: dont reconnect on 401
This commit is contained in:
@@ -178,6 +178,7 @@ export class CustomSocket {
|
||||
protected onDisconnect() {
|
||||
// Connection attempts
|
||||
let connectionAttempts = this.connectionAttempts;
|
||||
let shouldReconnect = true;
|
||||
|
||||
const logger = this.logger;
|
||||
const connect = this.connect.bind(this);
|
||||
@@ -210,6 +211,7 @@ export class CustomSocket {
|
||||
// Unauthorized - Invalid/missing API key.
|
||||
4401: async () => {
|
||||
this.logger.debug('Invalid API key, waiting for new key...');
|
||||
shouldReconnect = false;
|
||||
},
|
||||
// Request Timeout - Mothership disconnected us.
|
||||
4408: async () => {
|
||||
@@ -285,6 +287,11 @@ export class CustomSocket {
|
||||
logger.error('Connection closed with code=%s reason="%s"', code, (error as Error).message);
|
||||
}
|
||||
|
||||
// We shouldn't reconnect
|
||||
if (!shouldReconnect) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// Wait a few seconds
|
||||
await sleep(backoff(connectionAttempts, ONE_MINUTE, 5));
|
||||
|
||||
Reference in New Issue
Block a user