Home > Mobile >  For help, the problem of android netty Java. IO. IOException: Software under caused connection abort
For help, the problem of android netty Java. IO. IOException: Software under caused connection abort

Time:11-20

Recently on android do a simple netty client, is basically according to the official website of examples to do
http://netty.io/4.1/xref/io/netty/example/securechat/package-summary.html

ChatClient:
Final SslContext sslCtx=SslContextBuilder. ForClient () trustManager (InsecureTrustManagerFactory. INSTANCE.) the build ();
The bootstrap=new bootstrap ()
Group (group)
Channel (NioSocketChannel. Class)
Handler (new SecureChatClientInitializer (sslCtx, user_code));

The bootstrap. Option (ChannelOption SO_KEEPALIVE, true);
The bootstrap. Option (ChannelOption TCP_NODELAY, true);
The bootstrap. Option (ChannelOption SO_TIMEOUT, 5000);

Cf.=the bootstrap connect (new InetSocketAddress (HOST, PORT));

SecureChatClientInitializer:
Pipeline. AddLast (sslCtx newHandler (ch. Alloc (), the HOST, PORT));

//On the top of the SSL handler, add the text line codec.
Pipeline. AddLast (new DelimiterBasedFrameDecoder (8192, Delimiters. LineDelimiter ()));
Pipeline. AddLast (new StringDecoder ());
Pipeline. AddLast (new StringEncoder ());
Pipeline. AddLast (" ping ", new IdleStateHandler (5, 5, 5 * 3, TimeUnit. SECONDS));

//and then the business logic.
Pipeline. AddLast (new SecureChatClientHandler (usercode));

SecureChatClientHandler:

Public void channelRead0 (ChannelHandlerContext CTX, String MSG) throws the Exception {
System. Err. Println (MSG);
}

@ Override
Public void exceptionCaught (ChannelHandlerContext CTX, Throwable cause) {
Cause the printStackTrace ();
CTX. Close ();
}

Netty client written in service, the odd thing was app page keep activity is normal when receiving and sending messages, even on a computer with a usb line debugging of time also is normal, once pulled out debugging line, and put the app running in the background, and about 40 s time server connection lost will happen, can again even after the reconnection, and submit them to the error of this Java IO. IOException: Software under caused connection abort

To be sure the service has been in operation is not kill, but why such a strange thing,

Connection debugging on line and is not even on specific what's the difference?
O master told

CodePudding user response:

Your account for 1/f, first for worship

CodePudding user response:

You need to do the Service keep alive; At the front desk and visible service does not generally be recycled; Service if into the background, it is easy to be killed;
Combining with the Service keep alive, realize the Socket connection long;

Give a reference solution Service keep alive: https://www.jianshu.com/p/22a708c74c1e

CodePudding user response:

The building Lord solved? I also appear this problem
Is not a problem keep alive, my Service is a process of single, process is not to kill, so is not the problem of Service

CodePudding user response:

Which step is called a Java. IO. IOException: Software under caused connection abort exception?
Is the connection, the send data or receive data?

CodePudding user response:

Post stack to look over

CodePudding user response:

I also appear the same problem, error exception is as follows:

 
E/ServerHandler: the Error handling for request
Java. IO. IOException: Software under caused connection abort
At sun. Nio. Ch. FileDispatcherImpl. Read0 (Native Method)
At sun. Nio. Ch. SocketDispatcher. Read (43) SocketDispatcher. Java:
At sun. Nio. Ch. IOUtil. ReadIntoNativeBuffer (IOUtil. Java: 223)
At sun. Nio. Ch. IOUtil. Read (197) IOUtil. Java:
At sun. Nio. Ch. SocketChannelImpl. Read (421) SocketChannelImpl. Java:
At io.net ty. Buffer. UnpooledHeapByteBuf. SetBytes (UnpooledHeapByteBuf. Java: 291)
At io.net ty. Buffer. AbstractByteBuf. WriteBytes (AbstractByteBuf. Java: 1140)
At io.net ty. Channel. Socket. Nio. NioSocketChannel. DoReadBytes (NioSocketChannel. Java: 347)
At io.net ty. Channel. Nio. AbstractNioByteChannel $NioByteUnsafe. Read (148) AbstractNioByteChannel. Java:
At io.net, ty. Channel. Nio. NioEventLoop. ProcessSelectedKey (NioEventLoop. Java: 697)
At io.net, ty. Channel. Nio. NioEventLoop. ProcessSelectedKeysOptimized (NioEventLoop. Java: 632)
At io.net, ty. Channel. Nio. NioEventLoop. ProcessSelectedKeys (NioEventLoop. Java: 549)
At io.net, ty. Channel. Nio. NioEventLoop. Run (NioEventLoop. Java: 511)
At io.net ty. Util. Concurrent. SingleThreadEventExecutor $5. The run (918) SingleThreadEventExecutor. Java:
At io.net ty. Util. Internal. ThreadExecutorMap $2. The run (74) ThreadExecutorMap. Java:
At io.net ty. Util. Concurrent. FastThreadLocalRunnable. Run (30) FastThreadLocalRunnable. Java:
The at Java. Lang. Thread. The run (Thread. Java: 784)



O bosses give directions

CodePudding user response:

11 references jzp12 response:
is which step to invoke a Java IO. IOException: Software under caused connection abort exception?
Is the connection, the send data or receive data?


The
refer to 12 floor jzp12 reply:
post stack look


 Java. IO. IOException: Software under caused connection abort 
At sun. Nio. Ch. FileDispatcherImpl. Read0 (Native Method)
At sun. Nio. Ch. SocketDispatcher. Read (43) SocketDispatcher. Java:
At sun. Nio. Ch. IOUtil. ReadIntoNativeBuffer (IOUtil. Java: 223)
At sun. Nio. Ch. IOUtil. Read (197) IOUtil. Java:
At sun. Nio. Ch. SocketChannelImpl. Read (421) SocketChannelImpl. Java:
At org. Apache. Mina. Transport. Socket. Nio. NioProcessor. Read (317) NioProcessor. Java:
The at org. Apache. Mina. Transport. Socket. Nio. NioProcessor. Read (NioProcessor. Java: 45)
nullnullnullnullnullnullnullnullnullnull
  • Related