Netty Http Client does not work
yairogen
yairogen at gmail.com
Mon Sep 12 10:11:48 EDT 2011
I have a Http Client. I think I'm building the client properly.
When I get to the channel.write code, I don't get any error in the future
but the server responds with 501. The url in the GetMethod is OK since when
I copy the url to the browser it works. My only conclusion is that the netty
client is not sending the request properly.
Here is a snippet of the code:
bootstrap = new ClientBootstrap(new
NioClientSocketChannelFactory(Executors.newCachedThreadPool(),
Executors.newCachedThreadPool()));
bootstrap.setOption("connectTimeoutMillis", this.timeout);
bootstrap.setPipelineFactory(new HttpClientPipelineFactory());
allChannels = new DefaultChannelGroup();
ChannelFuture future = bootstrap.connect(new InetSocketAddress(this.host,
this.port));
if (!future.awaitUninterruptibly(timeout)) {
throw new IllegalStateException("could not connect within the timeout
period");
}
if (!future.isSuccess()) {
Throwable cause = future.getCause();
if (cause != null) {
throw new IllegalStateException(cause);
}
}
// future.addListener(new ConnectOk(request));
allChannels.add(future.getChannel());
channel = future.getChannel();
HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1,
HttpMethod.valueOf("get"), uri.toASCIIString());
ChannelFuture writeFuture = channel.write(request);
if (!writeFuture.awaitUninterruptibly(timeout)){
throw new javax.jms.IllegalStateException("write timeout");
}
if (!writeFuture.isSuccess()){
throw new
javax.jms.IllegalStateException(writeFuture.getCause().toString());
}
Any ideas? The server sends me an HTTP 501 error.
Thanks,
Yair
--
View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Netty-Http-Client-does-not-work-tp6783648p6783648.html
Sent from the Netty User Group mailing list archive at Nabble.com.
More information about the netty-users
mailing list