2017-02-26 3 views
1

웹 응용 프로그램의 HttpClient (버전 4.5.2)에 문제가 있습니다. 멀티 스레드 방식입니다. 정상적인 상황에서 연결 요청이 도착하면 연결은 풀에서 임대 된 다음 사용되었고 마지막으로 풀로 다시 릴리스되어 나중에 673890 상태로 연결하기위한 로그의 다음 부분으로 다시 요청에 사용됩니다. 제가 위에서 언급 한 정상적인 방법으로 언급 연결 (ID 673890) 여러 번 사용 후HttpClient에서 예기치 않은 연결이 닫습니다.

15 Feb 2017 018:25:54:115 p-1-thread-121 DEBUG PoolingHttpClientConnectionManager:249 - Connection request: [route: {}->http://127.0.0.1:8080][total kept alive: 51; route allocated: 4 of 100; total allocated: 92 of 500] 
15 Feb 2017 018:25:54:116 p-1-thread-121 DEBUG PoolingHttpClientConnectionManager:282 - Connection leased: [id: 673890][route: {}->http://127.0.0.1:8080][total kept alive: 51; route allocated: 4 of 100; total allocated: 92 of 500] 
15 Feb 2017 018:25:54:116 p-1-thread-121 DEBUG DefaultManagedHttpClientConnection:90 - http-outgoing-673890: set socket timeout to 9000 
15 Feb 2017 018:25:54:120 p-1-thread-121 DEBUG PoolingHttpClientConnectionManager:314 - Connection [id: 673890][route: {}->http://127.0.0.1:8080] can be kept alive for 10.0 seconds 
15 Feb 2017 018:25:54:121 p-1-thread-121 DEBUG PoolingHttpClientConnectionManager:320 - Connection released: [id: 673890][route: {}->http://127.0.0.1:8080][total kept alive: 55; route allocated: 4 of 100; total allocated: 92 of 500] 

, 나는 다음과 같은 코드에서 발생주의 사항 :

15 Feb 2017 018:25:54:130 p-1-thread-126 DEBUG PoolingHttpClientConnectionManager:249 - Connection request: [route: {}->http://127.0.0.1:8080][total kept alive: 55; route allocated: 4 of 100; total allocated: 92 of 500] 
15 Feb 2017 018:25:54:130 p-1-thread-126 DEBUG PoolingHttpClientConnectionManager:282 - Connection leased: [id: 673890][route: {}->http://127.0.0.1:8080][total kept alive: 54; route allocated: 4 of 100; total allocated: 92 of 500] 
15 Feb 2017 018:25:54:131 p-1-thread-126 DEBUG DefaultManagedHttpClientConnection:90 - http-outgoing-673890: set socket timeout to 9000 
15 Feb 2017 018:25:54:133 p-1-thread-126 DEBUG DefaultManagedHttpClientConnection:81 - http-outgoing-673890: Close connection 
15 Feb 2017 018:25:54:133 p-1-thread-126 DEBUG PoolingHttpClientConnectionManager:320 - Connection released: [id: 673890][route: {}->http://127.0.0.1:8080][total kept alive: 55; route allocated: 3 of 100; total allocated: 91 of 500] 

로그는 연결이 있음을 말한다 임대, 사용, 폐쇄 및 풀로 다시 풀어 놓았다. 그래서, 내 질문은 왜 연결이 닫혀있다? 왜 닫히고 풀에 풀려나는거야?

연결이 서버에 의해 종료 될 수 있다는 것을 알고 있지만 상황이 다릅니다. 이 경우 연결은 풀에서 임대되며 부실로 결정되므로 새 연결이 설정되고 사용되지만 위의 로그는 다른 동작을 보여줍니다.

HttpClient에서 연결을 닫기위한 두 가지 이유가 있음을 알고 있습니다. 첫 번째는 KeepAliveTime이 만료되어 유휴 상태가되는 것입니다. 둘째, 연결이 끊어지는 서버에 의해 닫힙니다. 연결을 닫을 다른 이유가 있습니까?

답변

0

HttpClient 메일 링리스트의 Oleg Kalnichevski의 답변과 내가 작성한 시험 결과를 토대로 문제는 'Connection : close'헤더가 다른 사람이 보낸 것으로 밝혀졌습니다. 동일한 상황으로 이어질 수있는 또 다른 원인은 HTTP/1.0 비 영구 연결을 사용하는 것입니다.

관련 문제