什么是http请求期间的连接超时 [英] What is a connection timeout during a http request

查看:1051
本文介绍了什么是http请求期间的连接超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现了有关连接超时"的两种解释:

I have found two explanations on "connection timeout":

  1. 当客户端在[超时]秒内未向服务器发送任何字节时,服务器将关闭套接字连接.它似乎与HTTP标头(Connection: keep-alive)有一些关系.

如果在此时间内未建立套接字连接,则客户端将在[超时]秒后停止尝试连接到服务器.

The client stops attempting to connect to the server after [timeout] seconds if the socket connection was not established during that time.

所以我对定义感到困惑.什么是连接超时?客户端连接超时和服务器端连接超时有什么区别?

So I am confused about the definition. What is a connection timeout? What is the difference between a client side connection timeout and a server side connection timeout?

TimeToLive,连接超时和请求超时之间有什么区别?

And what's the difference between TimeToLive, connection timeout and request timeout?

推荐答案

我将尝试非正式地回答.

I will try to answer it a little bit more informally.

连接超时-是必须在客户端和服务器之间建立连接的时间段.假设您将浏览器(客户端)导航到某个网站(服务器).发生的情况是您的浏览器开始监听来自该服务器的响应消息,但是由于各种原因该响应可能永远不会到达(例如,服务器处于脱机状态).因此,如果X秒钟后服务器仍然没有响应,您的浏览器将在等待时放弃",否则可能会因为等待永恒而卡住.

Connection timeout - is a time period within which a connection between a client and a server must be established. Suppose that you navigate your browser (client) to some website (server). What happens is that your browser starts to listen for a response message from that server but this response may never arrive for various reasons (e.g. server is offline). So if there is still no response from the server after X seconds, your browser will 'give up' on waiting, otherwise it might get stuck waiting for eternity.

请求超时-与以前的情况一样,客户端不愿意等待服务器的响应时间太长,服务器也不愿意将未使用的连接保持太长时间.一旦建立了服务器和客户端之间的连接,客户端必须通过向服务器发送信息来定期通知服务器它仍然存在.如果客户端无法在指定的时间内向服务器发送任何信息,则服务器会因为认为客户端不再在那里与之通信而直接丢弃此连接(为什么会浪费资源).

Request timeout - as in the previous case where client wasn't willing to wait for response from server for too long, server is not willing to keep unused connection alive for too long either. Once the connection between server and client has been established, client must periodically inform server that it is still there by sending information to that server. If client fails to send any information to server in a specified time, server simply drops this connection as it thinks that client is no longer there to communicate with it (why wasting resources meaninglessly).

生存时间(TTL)-是在数据包内部指定的一个值,该值是在创建数据包时设置的(通常为255),该值指示该数据包在数据包中可以保留多长时间.网络.当此数据包通过网络时,它到达位于数据包的原始地址与目的地之间的路径上的路由器.路由器每次重新发送数据包时,也会将其TTL值减1,如果该值下降到0,则路由器将丢弃该数据包,而不是重新发送该数据包,因为该数据包不再存在.这种机制用于防止网络被数据淹没,因为每个数据包只能在有限的时间"内驻留在其中.

Time to live (TTL) - is a value specified inside of a packet that is set when the packet is created (usually to 255) that tells how long the packet can be left alive in a network. As this packet goes through the network, it arrives at routers that sit on the path between the packet's origin and its destination. Each time the router resends the packet, it also decrements its TTL value by 1 and if that value drops to 0, instead of resending the packet, router simply drops it as the packet is not supposed to live any longer. This mechanism is used to prevent network from flooding by data as each packet can live inside of it for only limited amount of 'time'.

这篇关于什么是http请求期间的连接超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆