문서의 선택한 두 판 사이의 차이를 보여줍니다.
양쪽 이전 판 이전 판 다음 판 | 이전 판 다음 판 양쪽 다음 판 | ||
java:apache_http_client [2015/04/14 10:52] kwon37xi |
java:apache_http_client [2017/03/23 09:56] kwon37xi [Evict Idle Connections] |
||
---|---|---|---|
줄 21: | 줄 21: | ||
</ | </ | ||
+ | ===== Evict Idle Connections ===== | ||
+ | * KeepAlive 설정이 있을 경우, 서버에서 KeepAlive 시간 동안 사용되지 않은 커넥션(idle connection)을 죽이는 일이 생고 이를 '' | ||
+ | * 클라이언트 측에서도 Idle Connection을 주기적으로 지워주면 된다. | ||
+ | |||
+ | <code java> | ||
+ | HttpClient httpClient = HttpClientBuilder.create(). | ||
+ | .evictIdleConnections(2000L, | ||
+ | .... | ||
+ | .build(); | ||
+ | </ | ||
+ | * [[http:// | ||
+ | |||
+ | >> Please note this method has no effect if the instance of HttpClient is configuted to use a shared connection manager. | ||
+ | >> Please note this method may not be used when the instance of HttpClient is created inside an EJB container. | ||
===== Request Character Encoding ===== | ===== Request Character Encoding ===== | ||
==== 일반 ==== | ==== 일반 ==== | ||
줄 42: | 줄 56: | ||
* [[http:// | * [[http:// | ||
- | ===== JVM 버그 대응 | + | ===== Stale Check ===== |
- | * 아래와 같은 오류가 발생할 | + | * Keep Alive 상태시 서버와 클라이언트 모두 접속중인 커넥션을 상대방에게 알리지 않고 접속을 끊을 |
+ | * Stale Check에 대해 각 버전별 버그 여부 등을 확인하고 올바로 설정해야 한다. | ||
+ | * http:// | ||
+ | > HTTP specification permits both the client and the server to terminate a persistent (keep-alive) connection at any time without notice to the counterpart, | ||
+ | > | ||
+ | > See the http.connection.stalecheck parameter documentation for more information. | ||
- | |||
- | Caused by: java.util.NoSuchElementException: | ||
- | at java.util.ArrayList$Itr.next(ArrayList.java: | ||
- | at org.apache.http.impl.cookie.BestMatchSpec.formatCookies(BestMatchSpec.java: | ||
- | at org.apache.http.client.protocol.RequestAddCookies.process(RequestAddCookies.java: | ||
- | at org.apache.http.protocol.ImmutableHttpProcessor.process(ImmutableHttpProcessor.java: | ||
- | at org.apache.http.protocol.HttpRequestExecutor.preProcess(HttpRequestExecutor.java: | ||
- | at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java: | ||
- | at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java: | ||
- | at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java: | ||
- | </ | ||
- | * 이는 JVM의 Loop 최적화 관련 버그로 보이며 Java 8과 Java 7u60 이상 버전에서는 발생하지 않는다. 그 이하 버전에서는 JVM 시작시 다음과 옵션을 줘야 한다.< | ||
- | -XX: | ||
- | </ | ||
- | * [[https:// | ||
- | * [[http:// | ||
- | * [[https:// |