问题描述
限时送ChatGPT账号..我正在使用 Http Apache 组件来执行 http 交互.我需要调整我的 http 客户端.为此,我有两个参数:连接超时和连接请求超时.在库文档和源代码中(没有找到注释),我没有找到这些术语的定义.我需要知道它们到底是什么意思.可能它们是在 HTTP 协议文档中定义的,但我找不到.所以,我的问题是这两个术语是什么意思以及它们之间的区别.
I am using Http Apache Components to perform the http interactions. I need to adjust my http client. For this purpose I have two parameters: connection timeout and connection request timeout. In library documentation and in source code(no comments were found) I didn't found definition of this terms. I need to know what do they exactly mean. May be they were defined in HTTP protocol documentation but I can't find it. So, my question is what do this two terms mean and how they distinct from each other.
推荐答案
HttpClient
有一种设置连接和套接字超时的方法(setConnectionTimeout()
和 setTimeout()
) 根据 HttpClient javadocs.
HttpClient
has a way to set connection and socket timeout (setConnectionTimeout()
and setTimeout()
) according to the HttpClient javadocs.
Connection timeout
是与服务器建立连接之前的超时时间.
Connection timeout
is the timeout until a connection with the server is established.
Socket timeout
是接收数据的超时时间(socket timeout).
Socket timeout
is the timeout to receive data (socket timeout).
示例:
假设您将浏览器指向一个网页.如果服务器在 X 秒内没有 anwser,将发生连接超时.但是如果它建立了连接,那么服务器将开始为浏览器处理结果.如果在Y秒内没有结束这个处理,就会发生socket超时.
Let's say you point your browser to access a web page. If the server does not anwser in X seconds, a connection timeout will occur. But if it establishes the connection, then the server will start to process the result for the browser. If it does not ends this processing in Y seconds, a socket timeout will occur.
这篇关于连接和连接请求超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论