Skip to content

Commit

Permalink
Add a socketTimeout option to timeout http requests mullwar#135 as by…
Browse files Browse the repository at this point in the history
… lucdew
  • Loading branch information
mrummuka committed Jun 16, 2020
1 parent 17f69db commit fbc072a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:[email protected]:8080' // Optional. An HTTP proxy to be used.
},
webhook: { // Optional. Use webhook instead of polling.
Expand Down
4 changes: 3 additions & 1 deletion lib/telebot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit fbc072a

Please sign in to comment.