File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed
netty-android/src/main/java/com/goav/netty/Handler Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -108,6 +108,14 @@ protected void initChannel(SocketChannel ch) throws Exception {
108108 socketChannel = (SocketChannel ) future .channel ();
109109 logger .info ("socketChannel连接成功" );
110110 } else {
111+ try {
112+ //预防连接数超出系统上线
113+ future .channel ().disconnect ();
114+ future .channel ().close ();
115+ eventLoopGroup .rebuildSelectors ();
116+ } catch (Exception e ) {
117+
118+ }
111119 throw new InterruptedException ("connection fail." );
112120 }
113121 } catch (Exception e ) {
@@ -156,7 +164,7 @@ public boolean getConnectState() {
156164 @ Override
157165 protected void restart (boolean restart ) {
158166 reset ();
159- if (!getConnectState () && restart && !onDestrOY ) {
167+ if (!getConnectState () && restart && !onDestrOY && ClientNetWork . newInstance (). isNetworkAvailable () ) {
160168 reset2Connect ();
161169 }
162170 }
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ private void initThread() {
2323 public void run () {
2424 while (callBack != null && mContext != null ) {
2525 try {
26- Thread .sleep (3000 );
26+ Thread .sleep (5000 );
2727 } catch (InterruptedException e ) {
2828 e .printStackTrace ();
2929 }
@@ -63,7 +63,7 @@ private void pushNetWorkState() {
6363 }
6464 }
6565
66- private boolean isNetworkAvailable () {
66+ public boolean isNetworkAvailable () {
6767 if (mContext == null ) {
6868 isConnect = false ;
6969 return false ;
You can’t perform that action at this time.
0 commit comments