diff --git a/README.md b/README.md index a481110..db54089 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ const bot = new TeleBot({ timeout: 0, // Optional. Update polling timeout (0 - short polling). limit: 100, // Optional. Limits the number of updates to be retrieved. retryTimeout: 5000, // Optional. Reconnecting timeout (in ms). + socketTimeout: 30000, // Optional. Socket timeout (in ms). proxy: 'http://username:password@yourproxy.com:8080' // Optional. An HTTP proxy to be used. }, webhook: { // Optional. Use webhook instead of polling. diff --git a/lib/telebot.js b/lib/telebot.js index 1670ec8..c7e5fbf 100644 --- a/lib/telebot.js +++ b/lib/telebot.js @@ -39,6 +39,7 @@ class TeleBot { this.interval = poll.interval >= 0 ? poll.interval : 300; this.timeout = poll.timeout >= 0 ? poll.timeout : 0; this.retryTimeout = poll.retryTimeout >= 0 ? poll.retryTimeout : 5000; + this.socketTimeout = poll.socketTimeout >=0 ? poll.socketTimeout: 30000; this.webhook = cfg.webhook; @@ -347,7 +348,8 @@ class TeleBot { const options = { url: this.api + url, - json: true + json: true, + timeout: this.socketTimeout }; if (this.proxy) options.proxy = this.proxy;