When is a HTTP request lost?

1.7k views Asked by At

I need to send quite large HTTP requests from a mobile device. In what situation is the request lost (So that the data sent will have to be resent)?

What happen for example if there is no radio-connection for a few seconds? Does it depend on some decision in the network I can't control?

There is not timeouts on the server. I control the client and we can assume it is stable. The calls goes into some Curl libraries (POSIX C++, embedded Linux), and it is limited how much I can change it.

2

There are 2 answers

0
stivlo On

As "some" said, you should split your upload into parts, number them and re-assemble them on the other end. I once wrote a webservice to do that, so the client would have confirmation that a particular part has been received with the right checksum (for example a SHA-1 hash).

If the confirmation doesn't come because of a time out or the hash doesn't match, the client should re-send the part. I would advice to make each chunk small enough like 1-10 kb, depending on expected network speed (slow network smaller chunks).

1
some On

Some situations where the request is lost:

  • Power is lost in the mobile unit
  • Mobile unit loses contact with the net (radio waves can't reach the destination)
  • Programming error/memory-fault at the mobile device
  • Too many mobile devices try to send data at the same time
  • External interference on the radio-link
  • Power lost in network infrastructure
  • Cables mistakenly cut by workers
  • Fire, flooding, earthquake etc...

And then there are all the problems at the server end, like out of memory, timeouts of the request etc...

If possible, try to split the information in smaller segments. If something goes wrong, there is less information that has to be resent.


Updated 2011-01-27:

I might sound a bit pessimistic when I say that there's too many things that can go wrong and if anything can go wrong, it will.

On the transmitters side it's quite easy to check if the transmission was successful, if the server sends some sort of acknowledgment. It could be sent as the answer of the transfer request or by a separate query.

Depending on what you're using at the server side, you might be able to detect if the connection was lost (and all the data of that request was probably lost too). My opinion is that it's the senders responsibility to check if the transmission was successful, and resend it if it wasn't.

I don't know what kind of data you have, but I'm pretty sure it is possible to split it into smaller chunks. I can however not decide if it's desirable or not. But if you have mobile devices and it takes a long time to transfer the data, it probably is.