mirror of
https://github.com/yagop/node-telegram-bot-api
synced 2025-08-22 18:07:16 +00:00
fix: Handle rejected when open a webhook in a port that was already in use
Co-authored-by: windka <karl-heinz.wind.external@trumpf.com>
This commit is contained in:
parent
c4164a21ce
commit
ab0eb183ad
@ -45,17 +45,21 @@ class TelegramBotWebHook {
|
|||||||
/**
|
/**
|
||||||
* Open WebHook by listening on the port
|
* Open WebHook by listening on the port
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
*/
|
*/
|
||||||
open() {
|
open() {
|
||||||
if (this.isOpen()) {
|
if (this.isOpen()) {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
return new Promise(resolve => {
|
return new Promise((resolve, reject) => {
|
||||||
this._webServer.listen(this.options.port, this.options.host, () => {
|
this._webServer.listen(this.options.port, this.options.host, () => {
|
||||||
debug('WebHook listening on port %s', this.options.port);
|
debug('WebHook listening on port %s', this.options.port);
|
||||||
this._open = true;
|
this._open = true;
|
||||||
return resolve();
|
return resolve();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this._webServer.once('error', (err) => {
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user