title: Volley Timeout error during registration
body: <p>I am trying to build a chat application using GCM. I am using this for reference</p>
  
  <p><a href="http://www.androidhive.info/2016/02/android-push-notifications-using-gcm-php-mysql-realtime-chat-app-part-2/" rel="nofollow">http://www.androidhive.info/2016/02/android-push-notifications-using-gcm-php-mysql-realtime-chat-app-part-2/</a></p>
  
  <p>The username and email id is not added in database. When I am using Postman it works well. During  registration i am facing problem</p>
  
  <p>This is my LoginActivity</p>
  
  <pre><code>   public class LoginActivity extends AppCompatActivity {
  
  private String TAG = LoginActivity.class.getSimpleName();
  private EditText inputName, inputEmail;
  private TextInputLayout inputLayoutName, inputLayoutEmail;
  private Button btnEnter;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      /**
       * Check for login session. It user is already logged in
       * redirect him to main activity
       * */
      if (MyApplication.getInstance().getPrefManager().getUser() != null) {
          startActivity(new Intent(this, MainActivity.class));
          finish();
      }
  
      setContentView(R.layout.activity_login);
  
      Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
      setSupportActionBar(toolbar);
      inputLayoutName = (TextInputLayout) findViewById(R.id.input_layout_name);
      inputLayoutEmail = (TextInputLayout) findViewById(R.id.input_layout_email);
      inputName = (EditText) findViewById(R.id.input_name);
      inputEmail = (EditText) findViewById(R.id.input_email);
      btnEnter = (Button) findViewById(R.id.btn_enter);
  
      inputName.addTextChangedListener(new MyTextWatcher(inputName));
      inputEmail.addTextChangedListener(new MyTextWatcher(inputEmail));
  
      btnEnter.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              login();
          }
      });
  }
  
  /**
   * logging in user. Will make http post request with name, email
   * as parameters
   */
  private void login() {
      if (!validateName()) {
          return;
      }
  
      if (!validateEmail()) {
          return;
      }
  
      final String name = inputName.getText().toString();
      final String email = inputEmail.getText().toString();
  
      Log.e("endpoint loginb url",""+EndPoints.LOGIN);
      StringRequest strReq = new StringRequest(Request.Method.POST,
              EndPoints.LOGIN, new Response.Listener&lt;String&gt;() {
  
  
  
          @Override
          public void onResponse(String response) {
              Log.e(TAG, "response: " + response);
  
              try {
                  JSONObject obj = new JSONObject(response);
  
                  // check for error flag
                  if (obj.getBoolean("error") == false) {
                      // user successfully logged in
  
                      JSONObject userObj = obj.getJSONObject("user");
                      User user = new User(userObj.getString("user_id"),
                              userObj.getString("name"),
                              userObj.getString("email"));
  
                      // storing user in shared preferences
                      MyApplication.getInstance().getPrefManager().storeUser(user);
  
                      // start main activity
                      startActivity(new Intent(getApplicationContext(), MainActivity.class));
                      finish();
  
                  } else {
                      // login error - simply toast the message
                      Toast.makeText(getApplicationContext(), "" + obj.getJSONObject("error").getString("message"), Toast.LENGTH_LONG).show();
                  }
  
              } catch (JSONException e) {
                  Log.e(TAG, "json parsing error: " + e.getMessage());
                  Toast.makeText(getApplicationContext(), "Json parse error: " + e.getMessage(), Toast.LENGTH_SHORT).show();
              }
          }
      }, new Response.ErrorListener() {
  
          @Override
          public void onErrorResponse(VolleyError error) {
  
              if (error instanceof TimeoutError || error instanceof NoConnectionError) {
                  Log.e("Timeout", "timeout");
              } else if (error instanceof AuthFailureError) {
                  Log.e("AuthFailureError","AuthFailureError");
  
              } else if (error instanceof ServerError) {
                  Log.e("ServerError","ServerError");
              } else if (error instanceof NetworkError) {
                  Log.e("NetworkError","NetworkError");
              } else if (error instanceof ParseError) {
                  Log.e("ParseError","ParseError");
              }
          }
      }) {
  
          @Override
          protected Map&lt;String, String&gt; getParams() {
              Map&lt;String, String&gt; params = new HashMap&lt;&gt;();
              params.put("name", name);
              params.put("email", email);
  
              Log.e(TAG, "params: " + params.toString());
              return params;
          }
      };
  
      //Adding request to request queue
      MyApplication.getInstance().addToRequestQueue(strReq);
      strReq.setRetryPolicy(new RetryPolicy() {
          @Override
          public int getCurrentTimeout() {
              return 50000;
          }
  
          @Override
          public int getCurrentRetryCount() {
              return 50000;
          }
  
          @Override
          public void retry(VolleyError error) throws VolleyError {
  
          }
      });
  
  }
  
  private void requestFocus(View view) {
      if (view.requestFocus()) {
          getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
      }
  }
  
  // Validating name
  private boolean validateName() {
      if (inputName.getText().toString().trim().isEmpty()) {
          inputLayoutName.setError(getString(R.string.err_msg_name));
          requestFocus(inputName);
          return false;
      } else {
          inputLayoutName.setErrorEnabled(false);
      }
  
      return true;
  }
  
  // Validating email
  private boolean validateEmail() {
      String email = inputEmail.getText().toString().trim();
  
      if (email.isEmpty() || !isValidEmail(email)) {
          inputLayoutEmail.setError(getString(R.string.err_msg_email));
          requestFocus(inputEmail);
          return false;
      } else {
          inputLayoutEmail.setErrorEnabled(false);
      }
  
      return true;
  }
  
  private static boolean isValidEmail(String email) {
      return !TextUtils.isEmpty(email) &amp;&amp; android.util.Patterns.EMAIL_ADDRESS.matcher(email).matches();
  }
  
  private class MyTextWatcher implements TextWatcher {
  
      private View view;
      private MyTextWatcher(View view) {
          this.view = view;
      }
  
      public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
      }
  
      public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
      }
  
      public void afterTextChanged(Editable editable) {
          switch (view.getId()) {
              case R.id.input_name:
                  validateName();
                  break;
              case R.id.input_email:
                  validateEmail();
                  break;
          }
      }
  }
  }
  </code></pre>
  
  <p>This is MyApplication.java</p>
  
  <pre><code>   public class MyApplication extends Application {
  
  public static final String TAG = MyApplication.class
          .getSimpleName();
  
  private RequestQueue mRequestQueue;
  
  private static MyApplication mInstance;
  
  private MyPreferenceManager pref;
  
  @Override
  public void onCreate() {
      super.onCreate();
      mInstance = this;
  }
  
  public static synchronized MyApplication getInstance() {
      return mInstance;
  }
  
  public RequestQueue getRequestQueue() {
      if (mRequestQueue == null) {
          mRequestQueue = Volley.newRequestQueue(getApplicationContext());
  
      }
  
      return mRequestQueue;
  }
  
  public MyPreferenceManager getPrefManager() {
      if (pref == null) {
          pref = new MyPreferenceManager(this);
      }
  
      return pref;
  }
  
  public &lt;T&gt; void addToRequestQueue(Request&lt;T&gt; req, String tag) {
      req.setTag(TextUtils.isEmpty(tag) ? TAG : tag);
      getRequestQueue().add(req);
  }
  
  public &lt;T&gt; void addToRequestQueue(Request&lt;T&gt; req) {
      req.setTag(TAG);
      getRequestQueue().add(req);
  }
  
  public void cancelPendingRequests(Object tag) {
      if (mRequestQueue != null) {
          mRequestQueue.cancelAll(tag);
      }
  }
  
  public void logout() {
      pref.clear();
      Intent intent = new Intent(this, LoginActivity.class);
      intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
      startActivity(intent);
  }
  </code></pre>
  
  <p><strong>EDIT</strong>
  I used this but still not working.</p>
  
  <pre><code>   MyApplication.getInstance().addToRequestQueue(strReq);
  
      strReq.setRetryPolicy(new DefaultRetryPolicy(
              50000,
              DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
              DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
  
  
      RequestQueue requestQueue = Volley.newRequestQueue(getApplicationContext());
      requestQueue.add(strReq);
  </code></pre>
  
  <p>In logged the error and i am getting TimeOutError. Please help </p>