Skip to content
This repository has been archived by the owner on Apr 6, 2021. It is now read-only.

Android/Java client SDK : Blocks main thread for login error #140

Open
irfaan008 opened this issue Jul 6, 2017 · 6 comments
Open

Android/Java client SDK : Blocks main thread for login error #140

irfaan008 opened this issue Jul 6, 2017 · 6 comments

Comments

@irfaan008
Copy link

I am using below code to login to deepstream

private static void loginToDeepStream() {
	try {
		client = new DeepstreamClient(Const.CONST_CHAT_HOST);
		client.setRuntimeErrorHandler(new DeepstreamRuntimeErrorHandler() {
			@Override
			public void onException(Topic topic, Event event, String s) {
				log("Error : via callback" + s);
				client.close();
			}
		});
		LoginResult result = client.login();
		if (result.loggedIn()) {
			log("realtime server ready");
		} else log("realtime server not ready");
	} catch (DeepstreamException ex) {
		log("error : " + ex.getStackTrace());
	} catch (URISyntaxException ex) {
		log("error : " + ex.getStackTrace());
	}
}

I tried to call this function from main thread and from background thread both, but whenever network goes offline, it calls setRuntimeErrorHandler and shows black screen on device (android). Seems it tries to reconnect again.

How can I force deepstream to make connections on background instead of main thread. Currently even I am calling this method from doInBackground method of AsyncTask class, it blocks UI when setRuntimeErrorHandler gets call .

Please assist me better way if any to perform login and reconnection code without blocking UI thread

@irfaan008 irfaan008 changed the title Blocks main thread for login Android/Java client SDK : Blocks main thread for login Jul 6, 2017
@irfaan008 irfaan008 changed the title Android/Java client SDK : Blocks main thread for login Android/Java client SDK : Blocks main thread for login error Jul 6, 2017
@kirankiru
Copy link

Even i am Facing the same issue. is there any solution for this?

@yasserf
Copy link
Contributor

yasserf commented Oct 28, 2017

Im terribly sorry about this, we have a few issues raised about threading.

We are generally going to do a small rewrite soon to reflect alot of lessons learnt and will introduce async methods to allow users to deal with threading themselves if desired.

@irfaan008
Copy link
Author

@yasserf It would be really good if this handling could be done easily at mobile end as mobile app loses network more frequently and those network exception must be handled internally at deepstream end. Along with that deepstream should also expose method to override the exception behaviour and should notify the activity/service of no network access

@cdigiacinto
Copy link

Same issue also for me, do you feel we are going to see a solution for this any time soon?

@yasserf
Copy link
Contributor

yasserf commented Nov 2, 2017

Hey! We are working really hard to getting a new revamped JS and Java client out that addresses these problems. We will be looking at this next week and should have a beta out very soon.

@irfaan008
Copy link
Author

irfaan008 commented Nov 2, 2017 via email

@yasserf yasserf transferred this issue from deepstreamIO/deepstream.io Jul 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants