Configuring HttpTunnelingClientSocketChannel (Was: changes to HttpTunneling)

welcome123 flz_87 at 163.com
Mon Nov 1 21:52:23 EDT 2010


Hi,I find some difficulties transferring large amounts of data,I get the
following errors:
警告: Unexpected exception from downstream.
org.jboss.netty.handler.codec.frame.TooLongFrameException: An HTTP line is
larger than 4096 bytes.
	at
org.jboss.netty.handler.codec.http.HttpMessageDecoder.readLine(HttpMessageDecoder.java:592)
	at
org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:191)
	at
org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:107)
	at
org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:471)
	at
org.jboss.netty.handler.codec.replay.ReplayingDecoder.cleanup(ReplayingDecoder.java:542)
	at
org.jboss.netty.handler.codec.replay.ReplayingDecoder.channelDisconnected(ReplayingDecoder.java:450)
	at
org.jboss.netty.channel.Channels.fireChannelDisconnected(Channels.java:360)
	at org.jboss.netty.channel.socket.nio.NioWorker.close(NioWorker.java:587)
	at
org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink.handleAcceptedSocket(NioServerSocketPipelineSink.java:119)
	at
org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink.eventSunk(NioServerSocketPipelineSink.java:76)
	at
org.jboss.netty.handler.codec.oneone.OneToOneEncoder.handleDownstream(OneToOneEncoder.java:60)
	at
org.jboss.netty.handler.stream.ChunkedWriteHandler.handleDownstream(ChunkedWriteHandler.java:114)
	at org.jboss.netty.channel.Channels.close(Channels.java:720)
	at org.jboss.netty.channel.AbstractChannel.close(AbstractChannel.java:208)
	at
org.jboss.netty.channel.ChannelFutureListener$1.operationComplete(ChannelFutureListener.java:46)
	at
org.jboss.netty.channel.DefaultChannelFuture.notifyListener(DefaultChannelFuture.java:381)
	at
org.jboss.netty.channel.DefaultChannelFuture.addListener(DefaultChannelFuture.java:148)
	at Echo.EchoServerHandler.sendHttpResponse(EchoServerHandler.java:173)
	at Echo.CassaOperator.do_PUT(CassaOperator.java:54)
	at Echo.EchoServerHandler.messageReceived(EchoServerHandler.java:147)
	at
org.jboss.netty.handler.stream.ChunkedWriteHandler.handleUpstream(ChunkedWriteHandler.java:144)
	at
org.jboss.netty.handler.codec.http.HttpContentEncoder.messageReceived(HttpContentEncoder.java:83)
	at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:302)
	at
org.jboss.netty.handler.codec.http.HttpChunkAggregator.messageReceived(HttpChunkAggregator.java:158)
	at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:302)
	at
org.jboss.netty.handler.codec.replay.ReplayingDecoder.unfoldAndfireMessageReceived(ReplayingDecoder.java:516)
	at
org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:507)
	at
org.jboss.netty.handler.codec.replay.ReplayingDecoder.messageReceived(ReplayingDecoder.java:444)
	at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:274)
	at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:261)
	at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:350)
	at
org.jboss.netty.channel.socket.nio.NioWorker.processSelectedKeys(NioWorker.java:281)
	at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:201)
	at
org.jboss.netty.util.internal.IoWorkerRunnable.run(IoWorkerRunnable.java:46)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
2010-11-1 20:35:36 Echo.EchoServerHandler exceptionCaught
警告: Unexpected exception from downstream.
org.jboss.netty.handler.codec.frame.TooLongFrameException: An HTTP line is
larger than 4096 bytes.
	at
org.jboss.netty.handler.codec.http.HttpMessageDecoder.readLine(HttpMessageDecoder.java:592)
	at
org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:191)
	at
org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:107)
	at
org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:471)
	at
org.jboss.netty.handler.codec.replay.ReplayingDecoder.messageReceived(ReplayingDecoder.java:444)
	at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:274)
	at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:261)
	at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:350)
	at
org.jboss.netty.channel.socket.nio.NioWorker.processSelectedKeys(NioWorker.java:281)
	at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:201)
	at
org.jboss.netty.util.internal.IoWorkerRunnable.run(IoWorkerRunnable.java:46)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
some codes are following:
 public class EchoServer {  
      public static void main(String[] args) throws Exception {
    	  System.out.print("server start!\n");
          // Configure the server.
          ServerBootstrap bootstrap = new ServerBootstrap(
                  new NioServerSocketChannelFactory(
                          Executors.newCachedThreadPool(),
                          Executors.newCachedThreadPool()));
  
          // Set up the pipeline factory.
          bootstrap.setPipelineFactory(new EchoServerFactory());
  
          // Bind and start to accept incoming connections.
          bootstrap.bind(new InetSocketAddress(8585));
      }
  }
public class EchoServerFactory implements ChannelPipelineFactory {
      public ChannelPipeline getPipeline() throws Exception {
          // Create a default pipeline implementation.
         ChannelPipeline pipeline = pipeline();
         pipeline.addLast("decoder", new HttpRequestDecoder());
          // Uncomment the following line if you don't want to handle
HttpChunks.
          pipeline.addLast("aggregator", new
HttpChunkAggregator(1000000000));
          pipeline.addLast("encoder", new HttpResponseEncoder());
         // Remove the following line if you don't want automatic content
compression.
          pipeline.addLast("deflater", new HttpContentCompressor());
          pipeline.addLast("chunkedWriter", new ChunkedWriteHandler());
         pipeline.addLast("handler", new EchoServerHandler());
         return pipeline;
     }
Handler code:
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) {
	          HttpRequest request = this.request = (HttpRequest)
e.getMessage();
	          Map<String,String> headers = new HashMap();
	          if(!request.getHeaderNames().isEmpty()) {
	              for(String name: request.getHeaderNames()) {
	                  for(String value: request.getHeaders(name)) {
	                      System.out.println("HEADER: " + name + "=" + value);
	                      headers.put(name, value);
	                  }
	              }
	              System.out.println();
	          }//解析Header并输出
	          System.out.println("content  lenth: " +
request.getContentLength() + "#######");
	          final String path = request.getUri();
	          System.out.println("PATH: " + path);//解析path并输出
	          HttpMethod method = request.getMethod();
	          System.out.println("METHOD: " + method);//解析method并输出
	          //request.
	         ChannelBuffer content =request.getContent();
-- 
View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Configuring-HttpTunnelingClientSocketChannel-Was-changes-to-HttpTunneling-tp3376203p5695744.html
Sent from the Netty User Group mailing list archive at Nabble.com.



More information about the netty-users mailing list