mirror of
https://github.com/plantroon/mx-puppet-xmpp.git
synced 2024-11-14 23:41:40 +00:00
hopefully fix reconnect on polling error
This commit is contained in:
parent
4cdddc4996
commit
bce6e78245
@ -126,7 +126,8 @@ async function run() {
|
|||||||
data.state = client.getState;
|
data.state = client.getState;
|
||||||
await client.disconnect();
|
await client.disconnect();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
log.verbose("Failed to log in as new user, perhaps the password is worng?", err);
|
log.verbose("Failed to log in as new user, perhaps the password is worng?");
|
||||||
|
log.silly(err);
|
||||||
retData.error = "Username or password wrong";
|
retData.error = "Username or password wrong";
|
||||||
return retData;
|
return retData;
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ import { Client } from "./client";
|
|||||||
import * as skypeHttp from "skype-http";
|
import * as skypeHttp from "skype-http";
|
||||||
import { Contact as SkypeContact } from "skype-http/dist/lib/types/contact";
|
import { Contact as SkypeContact } from "skype-http/dist/lib/types/contact";
|
||||||
import { NewMediaMessage as SkypeNewMediaMessage } from "skype-http/dist/lib/interfaces/api/api";
|
import { NewMediaMessage as SkypeNewMediaMessage } from "skype-http/dist/lib/interfaces/api/api";
|
||||||
|
import { UnexpectedHttpStatusError } from "skype-http/dist/lib/errors";
|
||||||
import * as decodeHtml from "decode-html";
|
import * as decodeHtml from "decode-html";
|
||||||
import * as escapeHtml from "escape-html";
|
import * as escapeHtml from "escape-html";
|
||||||
import { MatrixMessageParser } from "./matrixmessageparser";
|
import { MatrixMessageParser } from "./matrixmessageparser";
|
||||||
@ -183,12 +184,16 @@ export class Skype {
|
|||||||
});
|
});
|
||||||
const MINUTE = 60000;
|
const MINUTE = 60000;
|
||||||
client.on("error", async (err: Error) => {
|
client.on("error", async (err: Error) => {
|
||||||
|
log.error("Error when polling");
|
||||||
|
log.error(err);
|
||||||
|
if (err.name === "UnexpectedHttpStatus") {
|
||||||
await this.puppet.sendStatusMessage(puppetId, "Error: " + err);
|
await this.puppet.sendStatusMessage(puppetId, "Error: " + err);
|
||||||
await this.puppet.sendStatusMessage(puppetId, "Reconnecting in a minute... ");
|
await this.puppet.sendStatusMessage(puppetId, "Reconnecting in a minute... ");
|
||||||
setTimeout(async () => {
|
|
||||||
await this.stopClient(puppetId);
|
await this.stopClient(puppetId);
|
||||||
|
setTimeout(async () => {
|
||||||
await this.startClient(puppetId);
|
await this.startClient(puppetId);
|
||||||
}, MINUTE);
|
}, MINUTE);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await client.connect();
|
await client.connect();
|
||||||
|
Loading…
Reference in New Issue
Block a user