cgbystrom / netty-tools Goto Github PK
View Code? Open in Web Editor NEWA collection of tools useful when working with JBoss Netty.
License: MIT License
A collection of tools useful when working with JBoss Netty.
License: MIT License
While it is easy to build netty-tools and deploy it locally, the barrier to using netty-tools would be even lower if it were deployed to Maven Central.
there are any way for msgpack http support?
Can we move the dependency on netty to a release build?
Hi
Thanks for the netty tools. I am using Netty4.1Beta, since Netty removed channel buffer and added Bytebuf i changed Channelbuffer into ByteBuf and tried. I could send the request properly, server could decode it properly and it could respond, but after server send the response, client hanging and it could not read the response. I tried with debugger, it is getting hanged when it tries to read asynchronously. In this line byte aByte = input.take(); - TNettyTransport.java it is getting hanged. Can you please help me to pass this? Can you provide any sample code for Netty4.1Beta?
Thanks
The maven source plugin says that the JDK compliance is 1.5 whereas the code needs 1.6.
Specifically, the @OverRide annotation cannot be used for interface implmentations in 1.5. This problem is seen in two classes: ThriftHttpClientPipelineFactory & ThriftHttpServerPipelineFactory
I cloned the git repo and ran 'mvn compile' (using Maven 3.0.3). First, I get these warnings:
[WARNING]
[WARNING] Some problems were encountered while building the effective model for se.cgbystrom.netty:netty-tools:jar:1.2.7-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 52, column 21
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-source-plugin is missing. @ line 60, column 21
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
Then I get this error -- presumably maven3 doesn't like the way the embedded-repo has been specified:
[ERROR] Failed to execute goal on project netty-tools: Could not resolve dependencies for project se.cgbystrom.netty:netty-tools:jar:1.2.7-SNAPSHOT: Failure to find org.apache.thrift:thrift:jar:2009-08-26 in ...
The following patch fixes the issues (note that Thrift 0.6.1 onwards is available in Maven central):
--- pom.xml
+++ pom.xml
@@ -29,8 +29,8 @@
</dependency>
<dependency>
<groupId>org.apache.thrift</groupId>
- <artifactId>thrift</artifactId>
- <version>2009-08-26</version>
+ <artifactId>libthrift</artifactId>
+ <version>0.6.1</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -52,6 +52,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
+ <version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
@@ -59,6 +60,7 @@
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
+ <version>2.1.1</version>
<executions>
<execution>
<id>attach-sources</id>
@@ -79,15 +81,5 @@
<enabled>false</enabled>
</snapshots>
</repository>
- <repository>
- <id>embedded-repo</id>
- <url>file://${basedir}/embedded-repo</url>
- </repository>
- <repository>
- <id>maven2-repository.dev.java.net</id>
- <name>Java.net Repository for Maven</name>
- <url>http://download.java.net/maven/2/</url>
- <layout>default</layout>
- </repository>
</repositories>
</project>
I'm the websocket client example using your code and I'm getting:
java.lang.IllegalArgumentException: invalid version format: <HTML>
at org.jboss.netty.handler.codec.http.HttpVersion.<init>(HttpVersion.java:102)
at org.jboss.netty.handler.codec.http.HttpVersion.valueOf(HttpVersion.java:62)
at org.jboss.netty.handler.codec.http.HttpResponseDecoder.createMessage(HttpResponseDecoder.java:104)
at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:189)
at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:101)
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:500)
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.messageReceived(ReplayingDecoder.java:435)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255)
at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:88)
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108)
at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:318)
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89)
at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.lang.IllegalArgumentException: invalid version format: <HEAD>
at org.jboss.netty.handler.codec.http.HttpVersion.<init>(HttpVersion.java:102)
at org.jboss.netty.handler.codec.http.HttpVersion.valueOf(HttpVersion.java:62)
at org.jboss.netty.handler.codec.http.HttpResponseDecoder.createMessage(HttpResponseDecoder.java:104)
at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:189)
at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:101)
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:500)
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.cleanup(ReplayingDecoder.java:554)
at org.jboss.netty.handler.codec.frame.FrameDecoder.channelDisconnected(FrameDecoder.java:365)
at org.jboss.netty.channel.Channels.fireChannelDisconnected(Channels.java:396)
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.close(AbstractNioWorker.java:360)
at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink.eventSunk(NioClientSocketPipelineSink.java:58)
at org.jboss.netty.handler.codec.oneone.OneToOneEncoder.handleDownstream(OneToOneEncoder.java:54)
at org.jboss.netty.channel.Channels.close(Channels.java:812)
at org.jboss.netty.channel.AbstractChannel.close(AbstractChannel.java:197)
at se.cgbystrom.netty.http.websocket.WebSocketClientHandler.exceptionCaught(WebSocketClientHandler.java:104)
at org.jboss.netty.handler.codec.frame.FrameDecoder.exceptionCaught(FrameDecoder.java:377)
at org.jboss.netty.channel.Channels.fireExceptionCaught(Channels.java:525)
at org.jboss.netty.channel.AbstractChannelSink.exceptionCaught(AbstractChannelSink.java:48)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255)
at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:88)
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108)
at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:318)
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89)
at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
WebSocket disconnected!
My websocket server uses Jetty. Is this because the websocket client doesn't support the websocket protocol offered by the server?
Thanks
Hi!
There's something wrong with PoolArena in 4.0.0.Beta1.
If I have a simple Http client pipeline initialized like this:
public class HttpClientIntializer extends ChannelInitializer<SocketChannel> {
public void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast("codec", new HttpClientCodec());
pipeline.addLast("chunkedWriter", new ChunkedWriteHandler());
pipeline.addLast("result", new StringResponseHandler());
}
}
StringResponseHandler being this:
public class StringResponseHandler extends ChannelInboundMessageHandlerAdapter<Object> {
private String result;
@Override
public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
HttpResponse response = (HttpResponse) msg;
ByteBuf content = response.getContent();
result = content.toString(Charset.defaultCharset());
}
public String getResult() {
return result;
}
}
Now if I set my maxHeap to say -Xmx8m and do a simple GET request then I will get OutOfMemoryError with this stacktrace:
java.lang.OutOfMemoryError: Java heap space
at io.netty.buffer.PoolArena$HeapArena.newChunk(PoolArena.java:326)
at io.netty.buffer.PoolArena.allocateNormal(PoolArena.java:149)
at io.netty.buffer.PoolArena.allocate(PoolArena.java:138)
at io.netty.buffer.PoolArena.allocate(PoolArena.java:88)
at io.netty.buffer.PooledByteBufAllocator.newHeapBuffer(PooledByteBufAllocator.java:135)
at io.netty.buffer.AbstractByteBufAllocator.heapBuffer(AbstractByteBufAllocator.java:73)
at io.netty.buffer.AbstractByteBufAllocator.heapBuffer(AbstractByteBufAllocator.java:59)
at io.netty.buffer.AbstractByteBufAllocator.buffer(AbstractByteBufAllocator.java:38)
at io.netty.handler.codec.ReplayingDecoder.newInboundBuffer(ReplayingDecoder.java:346)
at io.netty.handler.codec.ReplayingDecoder.newInboundBuffer(ReplayingDecoder.java:267)
at io.netty.channel.CombinedChannelHandler.newInboundBuffer(CombinedChannelHandler.java:77)
at io.netty.channel.DefaultChannelHandlerContext.<init>(DefaultChannelHandlerContext.java:290)
at io.netty.channel.DefaultChannelPipeline.addLast(DefaultChannelPipeline.java:157)
at io.netty.channel.DefaultChannelPipeline.addLast(DefaultChannelPipeline.java:147)
at eu.plumbr.agent.http.HttpClientIntializer.initChannel(HttpClientIntializer.java:32)
at eu.plumbr.agent.http.HttpClientIntializer.initChannel(HttpClientIntializer.java:25)
at io.netty.channel.ChannelInitializer.channelRegistered(ChannelInitializer.java:70)
at io.netty.channel.DefaultChannelHandlerContext$1.run(DefaultChannelHandlerContext.java:83)
at io.netty.channel.DefaultChannelHandlerContext.fireChannelRegistered(DefaultChannelHandlerContext.java:954)
at io.netty.channel.DefaultChannelPipeline.fireChannelRegistered(DefaultChannelPipeline.java:867)
at io.netty.channel.AbstractChannel$AbstractUnsafe.register0(AbstractChannel.java:603)
at io.netty.channel.AbstractChannel$AbstractUnsafe.register(AbstractChannel.java:587)
at io.netty.channel.SingleThreadEventLoop$1.run(SingleThreadEventLoop.java:73)
at io.netty.channel.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:259)
at io.netty.channel.socket.nio.NioEventLoop.run(NioEventLoop.java:312)
at io.netty.channel.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:110)
at java.lang.Thread.run(Thread.java:722)
If I'd run the app for example with -Xmx32m and -XX:+HeapDumpOnOutOfMemoryError
then I can see in the heap dump that an instance of io.netty.buffer.PoolArena$HeapArena is holding a byte array of 16 megs.
Alpha7 doesn't have this problem.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.