Login, registration error with "No response received within reply timeout. ~"

Hi, my app is havinig some problem when I try to create a new account or login into cometchat server.

Below is the message I get.

No response received within reply timeout. Timeout was 15000ms (~15s). Used filter: No filter used or filter was 'null'.

I already checked this issue
and changed android sdk from 2.0.0 to 2.0.2.
But what has changed is from the message, which was “10000ms”, now is “15000ms”.

It might be user id related problem because when I try logging in with the same device and with different id, seems like it’s working.

Here is my login code

CometChat.login(uid, Constants.CALLS_API_KEY, new CometChat.CallbackListener<com.cometchat.pro.models.User>() {
        @Override
        public void onSuccess(com.cometchat.pro.models.User user) {
            QuickHelper.hideDialog();

            //activate push-noti.
            if(user!=null){
                topic = Constants.CALLS_API_ID+"_user_"+ user.getUid();
                FirebaseMessaging.getInstance().subscribeToTopic(topic);
            }
            getBaseView().startActivity(HomeActivity.class);
        }
        @Override
        public void onError(CometChatException e) {
            QuickHelper.hideDialog();

            //cancel push noti-
            topic = Constants.CALLS_API_ID+"_user_"+ user.getUsername();
            FirebaseMessaging.getInstance().unsubscribeFromTopic(topic);

            //back4app logout
            user.logOut();

            e.printStackTrace();
            getBaseView().toastMessage(e.getMessage());
        }
    });

Thank you for your support.

1 Like

Symptom update

With device A
-user id “X”
: creation error with above message. but user id has created
: login fail

-user id “Y” (which was created and logged in successfully with device B)
: login succeeded

With device B
-user id “X” (which was created above with the error message)
: login succeeded

-user id “Y”
: creation succeeded
: login succeeded

1 Like

Hello @syChoi,
Can you also please share the error you received while creating the user ?
We tried replicating this at our end and were unable to do so.
Can you also, please share the code snippet you are using to create the user so that we can have a look at the same and try to get to the cause of the issue…?

1 Like
  1. It was with my friends phone and I’d got the message from an alert message. (which is the string value of below code’s “String returnResult”. I will point it on below code with comment)

  2. Code for creating user

//1-1. called from a Presenter

new CometChatCreateUser((RegisterActivity) context,RegisterPresenter.this, userName).execute();

//1-2. asyncTask class for creating user

package com.test.test.AsyncTask;

import android.os.AsyncTask;

import com.test.test.Activity.RegisterActivity;
import com.test.test.App.Constants;
import com.test.test.Presenter.RegisterPresenter;

import org.json.JSONObject;

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.URL;

import javax.net.ssl.HttpsURLConnection;

public class CometChatCreateUser extends AsyncTask<String, Integer, String> {

	private RegisterPresenter registerPresenter;
	private RegisterActivity registerActivity;
	private String userId;
	private String fullName;


	public CometChatCreateUser(RegisterActivity registerActivity, RegisterPresenter registerPresenter, String userName) {
   		this.registerActivity = registerActivity;
		this.registerPresenter = registerPresenter;
		this.userId = userName;
		this.fullName = userName;
	}

	@Override
	protected String doInBackground(String... strings ) {
		String createUserEndpoint = "https://api-%s.cometchat.io/v2.0/users";

		String returnResult = "fail";
		try {
			URL url = new URL(String.format(createUserEndpoint, Constants.REGION));
			HttpsURLConnection httpsURLConnection = (HttpsURLConnection) url.openConnection();
			httpsURLConnection.setReadTimeout(10000);
			httpsURLConnection.setConnectTimeout(15000);
			httpsURLConnection.setRequestMethod("POST");
			httpsURLConnection.setDoInput(true);
			httpsURLConnection.setDoOutput(true);

			// Adding the necessary headers

			httpsURLConnection.setRequestProperty("appid", Constants.CALLS_API_ID);
			httpsURLConnection.setRequestProperty("apikey", Constants.CALLS_API_KEY);
			httpsURLConnection.setRequestProperty("Content-Type", "application/json");
			httpsURLConnection.setRequestProperty("Accept", "application/json");

			// Creating the JSON with post params

			JSONObject userData = new JSONObject();
			userData.put("uid", userId);
			userData.put("name", fullName);

			OutputStream outputStream = new BufferedOutputStream(httpsURLConnection.getOutputStream());
			BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outputStream, "utf-8"));
			writer.write(userData.toString());
			writer.flush();
			writer.close();
			outputStream.close();

			int responseCode = httpsURLConnection.getResponseCode();
			String responseMessage = httpsURLConnection.getResponseMessage();
			String result = new String();
			InputStream inputStream = null;
			if (responseCode >= 400 && responseCode <= 499) {
				inputStream = httpsURLConnection.getErrorStream();
			} else {
				inputStream = httpsURLConnection.getInputStream();
			}
			BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
			String inputLine;
			while ((inputLine = bufferedReader.readLine()) != null) {
				result += inputLine;
			}
			if (responseCode == 200) {

				returnResult="success";
			} else {
				returnResult = result;
			}
		} catch (Exception e) {
			e.printStackTrace();

			//here is where I get the 15000ms~ message
			returnResult=e.getMessage();
		}

		return returnResult;
	}

	@Override
	protected void onProgressUpdate(Integer... values) {
		super.onProgressUpdate(values);
	}

	@Override
	protected void onPostExecute(String returnResult) {
		super.onPostExecute(returnResult);
		registerPresenter.afterCometChatCreateUser(returnResult, registerActivity, userId);
	}

}