简体   繁体   English

HTTP请求何时丢失?

[英]When is a HTTP request lost?

I need to send quite large HTTP requests from a mobile device. 我需要从移动设备发送相当大的HTTP请求。 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. 这些调用进入某些Curl库(POSIX C ++,嵌入式Linux),并且限制了我可以更改的数量。

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: 更新于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. 但是,如果您拥有移动设备,并且传输数据需要花费很长时间,则可能是这样。

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). 我曾经编写过一个Web服务来执行此操作,因此客户端将确认已收到具有正确校验和(例如SHA-1哈希)的特定部分。

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-10 kb)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM