deepstream.io-client-java
deepstream.io-client-java copied to clipboard
Unsubscribe throw NPE
I'm running into the following error
Caused by: java.lang.NullPointerException:
Attempt to invoke interface method 'void io.deepstream.Endpoint.send(java.lang.String)' on a null object reference
at io.deepstream.Connection.send(Connection.java:114)
at io.deepstream.EventHandler.unsubscribe(EventHandler.java:68)
when I'm trying to unsubscribe
in onDestroy()
as
deepstreamClient.event.unsubscribe(channel, mChatEventListener);
the deepstreamClient
was initialized as deepstreamClient = new DeepstreamClient(url);
Any idea?
It appears the connection was lost and hence your trying to send something on a closed state.
What hook is 'onDestroy' exactly?
onDestroy() on Activity.
I was trying to close/unsubscribe to avoid any memory leak, coz these EvenListeners are anonymous inner classes. Is there any other cleaner way to remove them?
I guess it would great if we could add api's for
- removing those listeners (all listener or by channel name)
- removing ConnectionChangeListeners and RuntimeErrorHandlers
which can be used while closing or destroying the activity to avoid memory leaks.
Are you creating a new connection per activity?
Yes. Coz activities are independent in nature in my case. Do you suggest any alternatives? in either case it would be great if we could get clean api to tear down and clean up.