Jump to content

Php / https connection, detecting protocol error


benwa

Recommended Posts

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!

Link to comment
Share on other sites

  • 2 weeks later...

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.