更新时间:2021-11-21 22:00:35
我在使用 OKHttp3
时遇到了同样的问题.问题是我没有关闭每个请求的连接,并且对于客户端,相同的连接可用,而对于服务器则没有,因此服务器返回错误.
I had the same problem using OKHttp3
. The problem was that I didn't close the connection for each request and for the client the same connection was available and for the server not, for this reason the server returns a error.
解决方案是指示每个请求在完成时关闭连接.您必须在标题中添加一个标志来表明这一点.在OKHttp3
中是这样的:
The solution is indicating to each request to close the connection when it is finished. You have to add a flag in the header to indicate this. In OKHttp3
is like this:
Request request = new Request.Builder()
.url(URL)
.header("Connection", "close")
...