[
https://issues.apache.org/jira/browse/HTTPASYNC-83?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Sylvere Richard updated HTTPASYNC-83:
-------------------------------------
Comment: was deleted
(was: sample:
import java.io.IOException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.apache.http.HttpResponse;
import org.apache.http.client.CookieStore;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.concurrent.FutureCallback;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
import org.apache.http.impl.nio.client.HttpAsyncClients;
import org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager;
import org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor;
import org.apache.http.impl.nio.reactor.IOReactorConfig;
import org.apache.http.nio.reactor.ConnectingIOReactor;
public class TestShared {
static final int TIMEOUT = 30000;
public static void main(String[] args) throws Exception {
final String url = "http://www.apache.org";
//request is sent => ok
executeRequest(url, false);
//no request sent ?
executeRequest(url, true);
}
static void executeRequest(final String url, boolean shared)
throws InterruptedException, IOException {
final IOReactorConfig ioReactorConfig = IOReactorConfig.custom()
.setIoThreadCount(Runtime.getRuntime().availableProcessors())
.setConnectTimeout(TIMEOUT)
.setSoTimeout(TIMEOUT)
.build();
// Create a custom I/O reactort
final ConnectingIOReactor ioReactor = new
DefaultConnectingIOReactor(
ioReactorConfig);
// Create a connection manager with custom configuration.
final PoolingNHttpClientConnectionManager connManag = new
PoolingNHttpClientConnectionManager(
ioReactor);
final CookieStore cookieStore = new BasicCookieStore();
final CloseableHttpAsyncClient httpclient =
HttpAsyncClients.custom()
.setDefaultCookieStore(cookieStore)
.setConnectionManager(connManag)
.setConnectionManagerShared(shared)
.build();
// Start the client
httpclient.start();
final HttpGet request = new HttpGet(url);
// Execute request
final CountDownLatch latch = new CountDownLatch(1);
httpclient.execute(request, new FutureCallback<HttpResponse>() {
public void completed(final HttpResponse response) {
System.out.println("got result "+
response.getStatusLine());
latch.countDown();
}
public void failed(final Exception ex) {
ex.printStackTrace(System.out);
latch.countDown();
}
public void cancelled() {
System.out.println("cancelled");
latch.countDown();
}
});
boolean ret = latch.await(10, TimeUnit.SECONDS);
if(ret == false) {
System.out.println("no result...");
}
connManag.shutdown();
}
}
)
> request no sent when setConnectionManagerShared is set to true
> --------------------------------------------------------------
>
> Key: HTTPASYNC-83
> URL: https://issues.apache.org/jira/browse/HTTPASYNC-83
> Project: HttpComponents HttpAsyncClient
> Issue Type: Bug
> Affects Versions: 4.1-beta1
> Reporter: Sylvere Richard
> Attachments: TestShared.java
>
>
> I'm trying to use the setting setConnectionManagerShared(true) :
> final CloseableHttpAsyncClient httpclient =
> HttpAsyncClients.custom()
> .setDefaultCookieStore(cookieStore)
> .setConnectionManager(connManag)
> .setConnectionManagerShared(true)
> .build();
> But when setConnectionShared is true, the request is never sent.
> When set to false, everything works perfectly.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]