mirror of
https://github.com/yagop/node-telegram-bot-api
synced 2025-08-22 09:57:10 +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
|
||||
* @return {Promise}
|
||||
*/
|
||||
*/
|
||||
open() {
|
||||
if (this.isOpen()) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._webServer.listen(this.options.port, this.options.host, () => {
|
||||
debug('WebHook listening on port %s', this.options.port);
|
||||
this._open = true;
|
||||
return resolve();
|
||||
});
|
||||
|
||||
this._webServer.once('error', (err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user