mercredi 6 novembre 2019

How to stop Interchange of data between multiple requests on server?

Server specifications :

  • Laravel version 5.6
  • PHP 5.6

I am stuck in a strange condition where data between multiple POST requests are getting interchanged between them.

What I am Doing :

$request['photo1'] = base64_encode(file_get_contents(public_path('/storage/photo1.jpg')));

$request['photo2'] = base64_encode(file_get_contents(public_path('/storage/photo2.jpg')));

Here photo paths are from database. I am sending this data to external server using following code.

$url = config('app.ExternalUrl');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fieldString);

$result = curl_exec($ch);
curl_close($ch);
return $result;

Use Case:

Let we have 2 client requests CR1 and CR2 on server. Then, Image of CR2 (Either photo1 or photo2) are coming in CR1 and image of CR1(Either photo1 or photo2) are coming in CR2.

I think, This is happening when multiple client requests hit the server at the same time or during processing of one request another comes. Because we are getting 4-5 cases in a month.

Note: External server don't have access to our server. So, I cannot provide direct public URL in request.

Any suggestions to stop this?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire