Always getting timeout

316 views
Skip to first unread message

Gaurav Jha

unread,
Nov 15, 2017, 4:36:35 AM11/15/17
to asynchttpclient

I am using async-http-client-2.0.37.jar in my java application. I am always getting Request timeout

java.util.concurrent.TimeoutException: Request timeout to www.google.co.in/172.217.26.163:80 after 60000 ms
    at org.asynchttpclient.netty.timeout.TimeoutTimerTask.expire(TimeoutTimerTask.java:43)
    at org.asynchttpclient.netty.timeout.RequestTimeoutTimerTask.run(RequestTimeoutTimerTask.java:48)
    at io.netty.util.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:663)
    at io.netty.util.HashedWheelTimer$HashedWheelBucket.expireTimeouts(HashedWheelTimer.java:738)
    at io.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:466)
    at java.lang.Thread.run(Thread.java:748)

Please find my code which I am using below:

AsyncHttpClient asyncHttpClient = new DefaultAsyncHttpClient();
 asyncHttpClient.prepareGet("http://www.google.co.in/").execute(new AsyncCompletionHandler<Response>(){

                    public State onStatusReceived(final HttpResponseStatus status) throws Exception {
                        System.out.println(status.getStatusCode());
                        return State.CONTINUE;
                    }

                    @Override
                    public Response onCompleted(Response response) throws Exception{
                        System.out.println("completed : " + response.getStatusCode());
                        return response;
                    }

                    @Override
                    public void onThrowable(Throwable t){
                        t.printStackTrace();
                        System.out.println("throw");
                    }
                });

I am getting status code in the output as 200 but I am always getting the above timeout exception. I have tried different URLs as well, getting timeout for every URL. And one more issue is whenever I use https URL I don't even get status code, but it will timeout after 60s.

Please guide on what should I do to solve this.



Stéphane LANDELLE

unread,
Nov 15, 2017, 4:40:14 AM11/15/17
to asyncht...@googlegroups.com
Crystal ball says your organization requires you to set up a proxy to be able to reach internet.

Stéphane Landelle
GatlingCorp CEO


--
You received this message because you are subscribed to the Google Groups "asynchttpclient" group.
To unsubscribe from this group and stop receiving emails from it, send an email to asynchttpclient+unsubscribe@googlegroups.com.
To post to this group, send email to asynchttpclient@googlegroups.com.
Visit this group at https://groups.google.com/group/asynchttpclient.
For more options, visit https://groups.google.com/d/optout.

Gaurav Jha

unread,
Nov 15, 2017, 4:59:57 AM11/15/17
to asynchttpclient
Why do I need to setup a proxy to get this work, is it not possible to make HTTP requests without setting up proxy?
Will this also solve HTTPS issue?
If without proxy it won't connect to internet then how I was getting status codes?
To unsubscribe from this group and stop receiving emails from it, send an email to asynchttpclie...@googlegroups.com.
To post to this group, send email to asyncht...@googlegroups.com.

Stéphane LANDELLE

unread,
Nov 15, 2017, 5:09:32 AM11/15/17
to asyncht...@googlegroups.com
No idea why you get timeouts.
What's for sure is that your code is broken: AsyncCompletionHandler is a concrete class, with some logic in "onStatusReceived" and you're breaking this logic as you override this method without calling super implementation.

Stéphane Landelle
GatlingCorp CEO


To unsubscribe from this group and stop receiving emails from it, send an email to asynchttpclient+unsubscribe@googlegroups.com.
To post to this group, send email to asynchttpclient@googlegroups.com.

Gaurav Jha

unread,
Nov 15, 2017, 5:27:19 AM11/15/17
to asynchttpclient
OK sorry to bother you again, but I have also tried without onStatusReceived method as well but still getting timeouts. I am new to this so my questions might sound silly but please help me on this as I am stuck.

I used the below code without onStatusReceived


AsyncHttpClient asyncHttpClient = new DefaultAsyncHttpClient();
                asyncHttpClient.prepareGet("http://www.google.co.in").execute(new AsyncCompletionHandler<Response>(){



                    @Override
                    public Response onCompleted(Response response) throws Exception{
                        System.out.println("completed : " + response.getStatusCode());
                        return response;
                    }

                    @Override
                    public void onThrowable(Throwable t){
                        t.printStackTrace();
                        System.out.println("throw");
                    }
                });

Till now I haven't tried by setting up a proxy I will give that also a try. Any help is appreciated.

Gaurav Jha

unread,
Nov 15, 2017, 6:19:29 AM11/15/17
to asynchttpclient
I tried by setting up the proxy and still am getting timeouts. Not sure what is causing this.

Gaurav Jha

unread,
Nov 15, 2017, 8:31:57 AM11/15/17
to asynchttpclient
I used the example present in AsyncHttpClient repo (https://github.com/AsyncHttpClient/async-http-client/blob/master/example/src/main/java/org/asynchttpclient/example/completable/CompletableFutures.java) But I am still getting the following error :

Exception in thread "main" java.util.concurrent.CompletionException: java.util.concurrent.TimeoutException: Request timeout to www.example.com/93.184.216.34:80 after 60000 ms
    at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:292)
    at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:308)
    at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:593)
    at java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:577)
    at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:474)
    at java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:1977)
    at org.asynchttpclient.netty.NettyResponseFuture.abort(NettyResponseFuture.java:243)
    at org.asynchttpclient.netty.request.NettyRequestSender.abort(NettyRequestSender.java:406)

    at org.asynchttpclient.netty.timeout.TimeoutTimerTask.expire(TimeoutTimerTask.java:43)
    at org.asynchttpclient.netty.timeout.RequestTimeoutTimerTask.run(RequestTimeoutTimerTask.java:48)
    at io.netty.util.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:663)
    at io.netty.util.HashedWheelTimer$HashedWheelBucket.expireTimeouts(HashedWheelTimer.java:738)
    at io.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:466)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.util.concurrent.TimeoutException: Request timeout to www.example.com/93.184.216.34:80 after 60000 ms
    ... 6 more

Please guide what to do or what could be going wrong here.
Reply all
Reply to author
Forward
0 new messages