Skip to content

Commit 2777c26

Browse files
committed
reloadConnection
the `PATCH /reload/:instanceName` endpoint can be called in case of disconnection
1 parent 9593d32 commit 2777c26

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/whatsapp/services/whatsapp.service.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,13 @@ export class WAStartupService {
550550

551551
public async reloadConnection(): Promise<WASocket> {
552552
try {
553-
this.client = await this.setSocket();
553+
await new Promise((resolve) => {
554+
this.client.ws?.once('close', resolve);
555+
this.client.ws?.['socket']?.['terminate']?.();
556+
});
557+
this.client.ws['socket'] = null;
558+
await this.client.ws.connect();
559+
554560
return this.client;
555561
} catch (error) {
556562
this.logger.error(error);

0 commit comments

Comments
 (0)