Hi,
I got following error when I was trying to proxy a file upload using little proxy.
Request doesn't go the real server. Exception is thrown before that.
jvm 1 | 2015-05-19 21:15:31,829 DEBUG ClientToProxyConnection [] [LittleProxy-ClientToProxyWorker-2] - (AWAITING_INITIAL): Configuring ChannelPipeline jvm 1 | 2015-05-19 21:15:31,830 DEBUG ClientToProxyConnection [] [LittleProxy-ClientToProxyWorker-2] - (AWAITING_INITIAL): Created ClientToProxyConnection jvm 1 | 2015-05-19 21:15:31,831 DEBUG ClientToProxyConnection [] [LittleProxy-ClientToProxyWorker-2] - (AWAITING_INITIAL) [id: 0x3fd92bb1, /127.0.0.1:34704 => /127.0.0.1:8082]: Connected jvm 1 | 2015-05-19 21:15:32,831 ERROR ClientToProxyConnection [] [LittleProxy-ClientToProxyWorker-2] - (AWAITING_INITIAL) [id: 0x3fd92bb1, /127.0.0.1:34704 => /127.0.0.1:8082]: Caught an exception on ClientToProxyConnection jvm 1 | java.lang.UnsupportedOperationException: unsupported message type: DefaultFullHttpResponse (expected: ByteBuf, FileRegion) jvm 1 | at io.netty.channel.nio.AbstractNioByteChannel.filterOutboundMessage(AbstractNioByteChannel.java:276) jvm 1 | at io.netty.channel.AbstractChannel$AbstractUnsafe.write(AbstractChannel.java:654) jvm 1 | at io.netty.channel.DefaultChannelPipeline$HeadContext.write(DefaultChannelPipeline.java:1054) jvm 1 | at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:658) jvm 1 | at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:716) jvm 1 | at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:706) jvm 1 | at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:741) jvm 1 | at io.netty.handler.codec.http.HttpObjectAggregator.decode(HttpObjectAggregator.java:131) jvm 1 | at io.netty.handler.codec.http.HttpObjectAggregator.decode(HttpObjectAggregator.java:54) jvm 1 | at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:89) jvm 1 | at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333) jvm 1 | at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319) jvm 1 | at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) jvm 1 | at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333) jvm 1 | at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319) jvm 1 | at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86) jvm 1 | at org.littleshoot.proxy.impl.ProxyConnection$RequestReadMonitor.channelRead(ProxyConnection.java:699) jvm 1 | at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333) jvm 1 | at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319) jvm 1 | at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:163) jvm 1 | at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333) jvm 1 | at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319) jvm 1 | at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86) jvm 1 | at org.littleshoot.proxy.impl.ProxyConnection$BytesReadMonitor.channelRead(ProxyConnection.java:676) jvm 1 | at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333) jvm 1 | at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319) jvm 1 | at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:787) jvm 1 | at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:130) jvm 1 | at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511) jvm 1 | at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468) jvm 1 | at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382) jvm 1 | at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354) jvm 1 | at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116) jvm 1 | at java.lang.Thread.run(Thread.java:744) jvm 1 | 2015-05-19 21:15:32,836 DEBUG ClientToProxyConnectio
I'm using following CURL to send the request.
curl -v -H "Content-Type: multipart/form-data" -k http://localhost:8082/group/upload -F csv=@"Contact-List-with-names.csv" -F appId="APP_000001" -F groupId="GRP_000001"
My Filter looks like follows.
new HttpFiltersSourceAdapter() { public HttpFilters filterRequest(HttpRequest originalRequest, ChannelHandlerContext ctx) { return new HttpFiltersAdapter(originalRequest) { @Override public HttpResponse clientToProxyRequest(HttpObject httpObject) { // TODO: implement your filtering here ???? if(httpObject instanceof FullHttpRequest){ FullHttpRequest httpRequest = (FullHttpRequest)httpObject; httpRequest.headers().remove("Host") httpRequest.headers().add("Host", "localhost:8080") } return null; } @Override public HttpResponse proxyToServerRequest(HttpObject httpObject) { // TODO: implement your filtering here ???? return null; } @Override public HttpObject serverToProxyResponse(HttpObject httpObject) { // TODO: implement your filtering here ???? return httpObject; } @Override public HttpObject proxyToClientResponse(HttpObject httpObject) { // TODO: implement your filtering here ???? return httpObject; } }; } }
I get above error even when real server is down as well. What am I doing wrong here?
Thanks and Regards,
Sandarenu.