Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AndroidRuntime: FATAL EXCEPTION #19

Open
nitinagr opened this issue Nov 13, 2017 · 5 comments
Open

AndroidRuntime: FATAL EXCEPTION #19

nitinagr opened this issue Nov 13, 2017 · 5 comments

Comments

@nitinagr
Copy link

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

@sacOO7
Copy link
Owner

sacOO7 commented Nov 13, 2017

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");
                    }
                }
        });

@nitinagr
Copy link
Author

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.

@sacOO7
Copy link
Owner

sacOO7 commented Nov 14, 2017

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.

@sacOO7
Copy link
Owner

sacOO7 commented Jan 24, 2018

Hi @nitinagr is your problem got solved? If it is let me know, I am closing this issue soon

@nitinagr
Copy link
Author

nitinagr commented Jan 25, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants