M
M
mitaichik2016-12-16 01:00:45
PHP
mitaichik, 2016-12-16 01:00:45

How to stop php execution when a request is terminated?

Hello! I have a backend (php-fpm + nginx) and mobile clients.
Judging by the nginx logs, quite often a situation occurs when either the Internet is cut off for clients, or the request is canceled by themselves. At the same time, the php script continues to perform the action.
I would like to stop it (there is no logic there, just a call to the strange api) when the client falls off. Can this be done somehow?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Grigory Esin, 2016-12-16
@xotey83

There is a function in php: ignore_user_abort(): php.net/manual/function.ignore-user-abort.php
And the corresponding option in php.ini
Should help.
UPD.
Section in the php documentation: php.net/manual/features.connection-handling.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question