XMPP fixes

This commit is contained in:
Zaid Abdulla committed 2020-12-08 02:08:25 -08:00
1 parent 79ede00ef2
commit 0e0380917f
3 files changed
+64 -17

No files matched your search

+4 -7
View File
@@ -244,11 +244,8 @@ const XMPP_PASSWORD = config.get("XMPP_PASSWORD") as string;
const XMPP_RESOURCE = crypto.randomBytes(8).toString("hex");
let xmppClient: XmppClient;
let xmppclientTimeout: NodeJS.Timeout;
function xmppClientOnError(err: Error): void {
clearTimeout(xmppclientTimeout);
xmppClient.disconnect();
xmppClient = null;
logger.error({
message: "XMPP exception",
@@ -257,8 +254,7 @@ function xmppClientOnError(err: Error): void {
});
}
function xmppClientTimeoutCallback(): void {
xmppClient.disconnect();
function xmppClientOnClose(): void {
xmppClient = null;
}
@@ -276,11 +272,12 @@ export async function xmppConnectionRequest(
username,
resource: XMPP_RESOURCE,
password: XMPP_PASSWORD,
timeout: 120000,
});
xmppClient.on("error", xmppClientOnError);
xmppClient.on("close", xmppClientOnClose);
xmppClient.unref();
}
clearTimeout(xmppclientTimeout);
setTimeout(xmppClientTimeoutCallback, 120000);
let username: string;
let password: string;