We are facing a strange problem and we don’t know how to proceed with it.
The problem is :
We have an App that creates report and when user submits it, it gets submitted on the server. We get acknowledgement as json response to know whether the operation is successful or not.
But for the 2 scenarios such as :
- User submits report. Before the response is received on the device, the network gets disconnected.
- User submits report and the response is not received within 120 sec and hence it times-out.
(Note : We are already putting timeout and WiFi check in the code.)
In both the cases, since the request has reached the server, the report gets submitted on server. Since the client does not receive any response, an error message is shown at client side. Now the user tries to submit the report again, which is incorrect and causes report duplication.
How can we handle this scenario?
Generate a unique submit ID when the user submits. If it fails, submit again using the same ID. The server will check if the ID exists and report back that the report already exists.