You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "ccin (JIRA)" <ji...@apache.org> on 2017/12/18 16:48:00 UTC
[jira] [Created] (HTTPASYNC-131) SocketTimeout doesn't work for me
ccin created HTTPASYNC-131:
------------------------------
Summary: SocketTimeout doesn't work for me
Key: HTTPASYNC-131
URL: https://issues.apache.org/jira/browse/HTTPASYNC-131
Project: HttpComponents HttpAsyncClient
Issue Type: Bug
Affects Versions: 4.1.3
Environment: httpasyncclient-4.1.3.jar
httpcore-4.4.7.jar
httpcore-nio-4.4.7.jar
Reporter: ccin
Priority: Critical
my code is like this,but the timeout config doesn't work for me,i still get a response more than 100ms which i expect a timeout exception.Is there something wrong with my code?ths for your help
{code:java}
RequestConfig requestConfig = RequestConfig.custom()
.setConnectTimeout(50)
.setSocketTimeout(50)
.setConnectionRequestTimeout(config.getConnectTimeout()).build();
Registry<SchemeIOSessionStrategy> sessionStrategyRegistry = RegistryBuilder
.<SchemeIOSessionStrategy>create()
.register("http", NoopIOSessionStrategy.INSTANCE)
.build();
IOReactorConfig ioReactorConfig = IOReactorConfig.custom()
.setIoThreadCount(Runtime.getRuntime().availableProcessors())
.setSoTimeout(50)
.setConnectTimeout(50)
.build();
ConnectingIOReactor ioReactor = new DefaultConnectingIOReactor(ioReactorConfig);
PoolingNHttpClientConnectionManager conMgr = new PoolingNHttpClientConnectionManager(
ioReactor, null, sessionStrategyRegistry, null);
conMgr.setMaxTotal(config.getPoolSize());
conMgr.setDefaultMaxPerRoute(config.getMaxPerRoute());
ConnectionConfig connectionConfig = ConnectionConfig.custom()
.setMalformedInputAction(CodingErrorAction.IGNORE)
.setUnmappableInputAction(CodingErrorAction.IGNORE)
.setCharset(Consts.UTF_8).build();
conMgr.setDefaultConnectionConfig(connectionConfig);
CloseableHttpAsyncClient client = HttpAsyncClients.custom().setConnectionManager(conMgr)
.setDefaultCookieStore(new BasicCookieStore())
.setDefaultRequestConfig(requestConfig).build();
client.start();
{code}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org