A
A
accountnujen2022-02-23 20:14:14
PHP
accountnujen, 2022-02-23 20:14:14

How to respond immediately and continue executing the script?

Telegram gives a minute to execute the script. If the answer is not received, the telegram will make a request again. I don't want to bother with rabbitMQ, so I just want to hack the answer.
I googled and saw this:

ignore_user_abort(true);
set_time_limit(0);
ob_start();
header('Connection: close');
header('Content-Length: '.ob_get_length());
ob_end_flush();
ob_flush();
flush();

It just doesn't work for me for some reason. Telegram still continues to hammer. Tell me what am I doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Immortal_pony, 2022-02-23
@accountnujen

If you don't want to use rabbitmq, at least use cron.
If your tasks take longer than a minute, then you need to accept this and implement the functionality in a human way:
1. We accept a request from an external system, put it in a queue, respond to an external system
2. In the background, we find all unprocessed tasks and process them, spending on it for as long as it takes.
PS And if it is important for you to provide the result of your script to an external system, then you need to figure out what you have been doing there for a whole minute.
A minute is a lot . My OS loads 3 times faster, and there is 100% more functionality than in your script.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question