skip to Main Content

I have a telegram Bot hosted on Heroku.

It needs to grab some content from a website
Parse it and send a messege to the user

$params['text'] = getRemoteContent("https://example.com/someData");

$t->send('sendMessage', $params);

but it exits after 30 seconds

2020-12-23T15:04:54.995957+00:00 app[web.1]: [23-Dec-2020 15:04:54] WARNING: [pool www] child 295, script '/app/index.php' (request: "GET /index.php?q=data&chat_id=000672000") execution timed out (30.626797 sec), terminating

I tried .user.ini but no change in results it still exits after 30 seconds

max_execution_time = 400

2

Answers


  1. try to reset your apache after change php.ini.

    other way, write

    <?
    set_time_limit(50);
    //your code
    

    This is a bad practice, it is better to write code that will shorten the loading time, for example to make processes work in parallel.

    updating:
    I saw you running on the "heroku".
    From a peek at their documentation, if you have to go over the 30s request timeout, you’ll need to use a background job:

    https://devcenter.heroku.com/articles/request-timeout

    Login or Signup to reply.
    • Web requests on Heroku come with a 30-second limit. From their Request timeout article:

    Web requests processed by Heroku are directed to your dynos via a number of Heroku routers. These requests are intended to be served by your application quickly. Best practice is to get the response time of your web application to be under 500ms […] Occasionally a web request may hang or take an excessive amount of time to process by your application. When this happens the router will terminate the request if it takes longer than 30 seconds to complete.

    Now this goes into more details and mentions an additional 55-second window: HTTP timeouts (in their article about Limits.)

    Connections to one-off dynos will be closed after one hour of inactivity

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search