My Netty communications classes work fine in a standard Java application but when I run them in an Android application I get a NullPointerException.
My question is if any Netty experts could point in the right direction for resolving this. Is it an incompatibility issue issue with Android or can you see anything in the stack trace that might indicate what I may be doing wrong?
I am using netty-3.4.0.Final.jar
I have added the internet permission to the AndroidManifest.xml
.
I have verified that I can successfully connect to the server using just raw socket (without Netty) in the android app.
After I call bootstrap.connect()
I can suspend execution at breakpoints in two threads. One in exceptionCaught()
and one in channelClosed()
.
The stack track below is from exception exceptionCaught()
.
The full source from this project is located on codeplex
in the elvemobileandroid project
.
I believe I actually saw the Android project work once which might indicate that the exception is not always thrown. Unfortunately I have not been able to get it to work again (even though I have made no project changes).
Thread [<1> main] (Suspended (breakpoint at line 172 in UptimeClientHandler))
UptimeClientHandler.exceptionCaught(ChannelHandlerContext, ExceptionEvent) line: 172
UptimeClientHandler(SimpleChannelUpstreamHandler).handleUpstream(ChannelHandlerContext, ChannelEvent) line: 117
DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline$DefaultChannelHandlerContext, ChannelEvent) line: 564
DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(ChannelEvent) line: 792
ReadTimeoutHandler(SimpleChannelUpstreamHandler).exceptionCaught(ChannelHandlerContext, ExceptionEvent) line: 143
ReadTimeoutHandler(SimpleChannelUpstreamHandler).handleUpstream(ChannelHandlerContext, ChannelEvent) line: 117
DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline$DefaultChannelHandlerContext, ChannelEvent) line: 564
DefaultChannelPipeline.sendUpstream(ChannelEvent) line: 559
Channels.fireExceptionCaught(Channel, Throwable) line: 533
NioClientSocketPipelineSink.connect(NioClientSocketChannel, ChannelFuture, SocketAddress) line: 152
NioClientSocketPipelineSink.eventSunk(ChannelPipeline, ChannelEvent) line: 97
DefaultChannelPipeline.sendDownstream(ChannelEvent) line: 574
Channels.connect(Channel, SocketAddress) line: 642
NioClientSocketChannel(AbstractChannel).connect(SocketAddress) line: 204
ClientBootstrap.connect(SocketAddress, SocketAddress) line: 230
ClientBootstrap.connect(SocketAddress) line: 183
ClientBootstrap.connect() line: 154
UptimeClient.run() line: 94
CommunicationTest.test() line: 32
ElveMobileActivity.onCreate(Bundle) line: 25
Instrumentation.callActivityOnCreate(Activity, Bundle) line: 1047
ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2627
ActivityThread.handleLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2679
ActivityThread.access$2300(ActivityThread, ActivityThread$ActivityRecord, Intent) line: 125
ActivityThread$H.handleMessage(Message) line: 2033
ActivityThread$H(Handler).dispatchMessage(Message) line: 99
Looper.loop() line: 123
ActivityThread.main(String[]) line: 4627
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]
Method.invoke(Object, Object...) line: 521
ZygoteInit$MethodAndArgsCaller.run() line: 868
ZygoteInit.main(String[]) line: 626
NativeStart.main(String[]) line: not available [native method]
This is my first post on stackoverflow, please let me know if there is any more information I may provide.
Thanks