benwa Posted November 24, 2011 Share Posted November 24, 2011 Hi, I have the following situation: - I have a client that is sending a HTTPS request to a php webpage on my server (with data in GET parameters) - On this webpage I execute some scripts. These scripts require some database lookups and can sometimes take a while. - If all code has succesfully finished, the webpage shows "OK" and if an error happened the webpage shows "ERROR" It is very important that both the client and me can detect if something is going wrong in this process. Because the scripts on my server can only be executed once for each request. Now, the client retry's the request if he doesn't get the "OK" and if he is unable to open the webpage and if a protocol error or timeout happens. This gives us the certainty that all request are succesfully received by my script. The problem is however, that if the client receives a "protocol error", I see that the script on my server was still executed. The client however thinks there was an error, and retry's a bit later. This results is a dubbel executed script. And I don't want this to happen. So the question is: how can I detect in my php script if the connection is still active and the client is still there? If the connection if not alive anymore and the client won't be able to detect the "OK", the script needs to reverse his action, so that the action won't be executed twice. hope someone can help me with this! Quote Link to comment https://forums.phpfreaks.com/topic/251721-php-https-connection-detecting-protocol-error/ Share on other sites More sharing options...
haku Posted December 3, 2011 Share Posted December 3, 2011 You can't exactly do this. PHP scripts do not contain tunnels with an open connection. They send a request, the data gets generated and sent back, whether the recipient is still there or not. The closest thing you could try doing is pinging the client at the end of the script and seeing if you get a response, but even then it wouldn't tell you whether or not the client got all the data, just that the client still exists. Quote Link to comment https://forums.phpfreaks.com/topic/251721-php-https-connection-detecting-protocol-error/#findComment-1293766 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.