更新时间:2021-11-06 22:03:30
你有没有做任何研究吗?在默认设置进行了详细的文档。以下是有关部分:
Did you do any research? The defaults are detailed in the documentation. Here's the relevant parts:
公共无效setConnectTimeout(INT超时)自:API级别1
public void setConnectTimeout (int timeout) Since: API Level 1
设定以毫秒为单位的超时值用于建立连接 要指出此URLConnection实例的资源。一个 SocketTimeoutException如果被抛出,如果连接不能 建立在这个时候。 默认为0,表示无限 暂停。
Sets the timeout value in milliseconds for establishing the connection to the resource pointed by this URLConnection instance. A SocketTimeoutException is thrown if the connection could not be established in this time. Default is 0 which stands for an infinite timeout.
公共无效setReadTimeout(INT超时)自:API级别1
public void setReadTimeout (int timeout) Since: API Level 1
设定在毫秒的超时值用于从输入读出 已建立的连接到资源的流。一个 SocketTimeoutException如果被抛出,如果连接不能 建立在这个时候。 默认为0,表示无限 暂停。
Sets the timeout value in milliseconds for reading from the input stream of an established connection to the resource. A SocketTimeoutException is thrown if the connection could not be established in this time. Default is 0 which stands for an infinite timeout.
也有是有这样一个字条超时:
Also there is this note on timeouts:
URLConnection的支持两个超时:连接超时和 读取超时。默认情况下,操作永不超时。
URLConnection supports two timeouts: a connect timeout and a read timeout. By default, operations never time out.
这可能是可能的,你正在连接的服务器超时客户端。
It might be possible that the server you are connecting to is timing out your client.