Assume following scenario:
In this case we meet situation where: - client does not know if his data was valid and been inserted properly - web server (rails 3.2 application) does not show any exception, no matter if it is behind apache proxy or not
I can't find how to handle such scenario in HTTP documentation. My question are:
a) should client expect that his data MAY be processed already? (so then try for example GET request to check if data has been submitted)
b) if not (a) - should server detect it? is there possibility to do it in rails? In such case changes can be reversed. In such case i would expect some kind of expection from rails application but there is not...
A Request-Timeout header is defined for Hypertext Transfer Protocol (HTTP). This end-to-end header informs an origin server and any intermediaries of the maximum time that a client will await a response to its request. A server can use this header to ensure that a timely response is generated.
Just remove future at the end of the block. Futures, like other Scala constructs, are immutable data structures which calling methods on them will return another futures. When you call onComplete method, it returns new future with your HttpResponse .
Although the difference is subtle, there are still differences between both error messages. The 504 Gateway Timeout error is returned when a server is acting as a gateway or proxy and has timed out. On the other hand, a 408 error is returned as a direct message from the active server itself.
The HyperText Transfer Protocol (HTTP) 408 Request Timeout response status code means that the server would like to shut down this unused connection. It is sent on an idle connection by some servers, even without any previous request by the client.
HTTP is a stateless protocol: Which means by definition you cannot know on the client side that the http-verb POST
has succeeded or not.
There are some techniques that web applications use to overcome this HTTP 'feature'. They include.
However, none of these are really going to help with your issue. When I have run into these types of issues in the past they are almost always the result of the server taking too long to process the web request.
There is a really great quote to that I whisper to myself on sleepless nights:
“The web request is a scary place, you want to get in and out as quick as you can” - Rick Branson
You want to be getting into and out of your web request in 100 - 500 ms. You meet those numbers and you will have a web application that will behave well/play well with web servers.
To that end I would suggest that you investigate how long your post's are taking and figure out how to shorten those requests. If you are doing some serious processing on the server side before doing dbms inserts you should consider handing those off to some sort of tasking/queuing system.
An example of 'serious processing' could be some sort of image upload, possibly with some image processing after the upload. An example of a tasking and queuing solution would be: RabbitMQ and Celery
An example solution to your problem could be:
Tighten up those web request and it will be a rare day that your client does not receive a response.
On that rare day that the client does not receive the data: How do you prevent multiple posts... I don't know anything about your data. However, there are some schema related things that you can do to uniquely identify your post. i.e. figure out on the server side if the data is an update
or a create
.
This answer covers some of the polling / streaming / websockets techniques you can use.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With