Question

I have a very simple client like so

private void start() throws IOReactorException, InterruptedException {
    DefaultHttpAsyncClient client = new DefaultHttpAsyncClient();

    HttpAsyncRequestProducer prod = HttpAsyncMethods.createGet("http://b1.bigde.nrel.gov:8080");

    HttpAsyncResponseConsumer<Object> handler = new MyResponseHandler();
    FutureCallback<Object> futureCb = new MyFutureCbHandler();
    client.execute(prod, handler, futureCb);

    log.info("now sleeping");
    Thread.sleep(30000);
    log.info("done sleeping");
}

The problem is no listener methods are ever called. MyResponseHandler is extending AsyncCharConsumer but nothing is called on him and nothing is called on FutureCallback. I never get a response.

NOTE 1: I need to be able to call client.execute and return way up the stack without interacting with Futures

NOTE 2: I need the listener methods called (and need them called as data comes in since the remote end is streaming back http chunking.

Is there a way to get this to work? or should I switch libraries?

thanks, Dean

Was it helpful?

Solution

It would help a great deal to start the client ;-)

client.start()

You might also want to shut it down when done.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top