http请求报错:80 failed to respond

A系统设置的接口为短连接
B系统设置的接口为长连接

B系统同一个接口调多次A系统的接口的时候,第一次请求完成之后,A系统会断开连接,而B系统不会断开连接,再次访问A系统的时候还是会用上一次请求的端口继续请求A系统,因为A系统已经释放了连接,所以端口会丢失,再试访问会报错:80 failed to respond

设置长、短连接的办法

String url = "http://10.21.101.131:9055/kims/httpDoRquest.do";
URI uri = URI.create(url);
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setConnection("Close");
HttpEntity httpEntity = new HttpEntity(httpHeaders);
BsResult response = HttpInvoker.getInstance().postForObject(uri, httpEntity, BsResult.class);

短连接:Connection: close
长连接:Connection: Keep-alive

你可能感兴趣的:(Http,http)