socketcluster-client-java
socketcluster-client-java copied to clipboard
AndroidRuntime: FATAL EXCEPTION
My connection with SC getting disconnected sometimes and when i try to send some msg app crashes with below error can you please help me here.
shutting down VM 11–13 09:20:56.221 3371–3371/git.cluster.io.socketclusterandroid E/AndroidRuntime: FATAL EXCEPTION: main Process: git.cluster.io.socketclusterandroid, PID: 3371 java.lang.NullPointerException: Attempt to invoke virtual method ‘void io.github.sac.Socket$Channel.publish(java.lang.Object)’ on a null object reference at git.cluster.io.socketclusterandroid.MainActivity$5.onClick(MainActivity.java:146) at android.support.v7.app.AlertController$ButtonHandler.handleMessage(AlertController.java:157) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.Act
Hey please make sure you are creating channel first and then publish on it.
Socket.Channel channel = socket.createChannel(channelName);
// message can have any data type
/**
* without acknowledgement
*/
channel.publish(message);
/**
* with acknowledgement
*/
channel.publish(message, new Ack() {
public void call(String channelName,Object error, Object data) {
if (error == null) {
System.out.println("Published message to channel "+channelName+" successfully");
}
}
});
That i am doing but when the connection is broken this exception crash the app.There should be a way to catch this exception and handle gracefully.
I think that shouldn't create a problem. I'm sure of that. Can you check if channel object become null after connection is broken.
Hi @nitinagr is your problem got solved? If it is let me know, I am closing this issue soon
Yes resolved.Please close it.
On Thu, Jan 25, 2018 at 12:37 AM, sachin shinde [email protected] wrote:
Hi @nitinagr https://github.com/nitinagr is your problem got solved? If it is let me know, I am closing this issue soon
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sacOO7/socketcluster-client-java/issues/19#issuecomment-360240062, or mute the thread https://github.com/notifications/unsubscribe-auth/ACzXABgzpgs8Q82qW--lUpkBXyHi-4eCks5tN39ogaJpZM4QcE4U .