ASmack, How to force a re-connection?

I have an implemented aSmack application (8-4.0.5) since we know it has an internal Reconnection control, but it is not statified. Since we have to wait 5 minutes multiple times to reconnect until we know it is a Good time to do this, so I implemented this:

private BroadcastReceiver mConnReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
    intent.getParcelableExtra(ConnectivityManager.EXTRA_OTHER_NETWORK_INFO);
               if(isNetworkAvailable()){
                   if(MyService.myServiceInstance!=null){
                       if(!MyService.connection.isConnected() || !MyService.connection.isAuthenticated()){
                           MyService.myServiceInstance.performReconnect();
                          // Which goes to Connect() and Authenticate()
                       }
                   }
                  LMApplication.getInstance().getPresistentJobManager().onNetworkChange(true);
               }

   }
}; 

      

but the problem is they try to connect at the same time (my manager and built-in manager) at the same time and as a result they connect to each other over and over again and every time I get this error:

11-10 14:58:09.069: W/PacketWriter(26439): Exception writing closing stream element
11-10 14:58:09.069: W/PacketWriter(26439): java.io.IOException: BufferedWriter is  
closed
11-10 14:58:09.069: W/PacketWriter(26439):  at    
java.io.BufferedWriter.checkNotClosed(BufferedWriter.java:130)
11-10 14:58:09.069: W/PacketWriter(26439):  at   
java.io.BufferedWriter.flush(BufferedWriter.java:122)
11-10 14:58:09.069: W/PacketWriter(26439):  at 
org.jivesoftware.smack.util.ObservableWriter.flush(ObservableWriter.java:44)
11-10 14:58:09.069: W/PacketWriter(26439):  at 
org.jivesoftware.smack.tcp.PacketWriter.writePackets(PacketWriter.java:190)
11-10 14:58:09.069: W/PacketWriter(26439):  at 
org.jivesoftware.smack.tcp.PacketWriter.access$000(PacketWriter.java:40)
11-10 14:58:09.069: W/PacketWriter(26439):  at 
org.jivesoftware.smack.tcp.PacketWriter$1.run(PacketWriter.java:77)

      

I think because 1 already completed the assignment and closed the post and the other saw that the author was closed, disconnect the connection! like 2 jealous kids!

so is there any idea what i can do here, like how can i disable exposure or force Reconnection?

+3


source to share


1 answer


I had to uninstall the autoreconnect aSamack system, and I did it completely on my own, so my application got stability.



0


source







All Articles