Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What to do when Http Post was completed successfully and while waiting for response internet connectivity lost?

I am sending data to server by using HTTP post and successfully it fired at the server. Now In between sending the data and waiting for server response, suddenly Due to network problem my android device gets internet connection lost. In device m able to show an alert dialog of connection lost, but at server side the data was already processed and it was updated in database ie MySQL server But my android device does not know this bcoz till it did not get any response from server. How to resolve it.

Whether it could be done on server side or in android app and How?

How server would know that android phone is not getting the response till now ?

Any Idea .. Waiting for the answer???

like image 448
Subhalaxmi Avatar asked Oct 19 '13 06:10

Subhalaxmi


1 Answers

For each request which is sent from device to server you should generate unique ID (check GUID for example)

then you send request with this id to server, if connection lost - trying to re-send with the same ID

on server side you have to implement check: if the query with ID was processed/inprocess/new

like image 194
Iłya Bursov Avatar answered Nov 15 '22 07:11

Iłya Bursov