title: java.net.SocketTimeoutException while uploading a long encoded string to server in android
body: <p>I am using httpok library for network requests. The code is working fine if i send only ID,Name,age etc
   but when i send the "encodedPhotoString" which is 
  a long string of the image to be uplaoded to server and is about 8000 characters the code is throwing java.net.SocketTimeoutException: timeout
  Exception. I have tried to change the connect timeout and read timeout but that's not working for me. I am using namecheap.com hosting server.
  Please help me with this issue. Thank you.</p>
  
  <pre><code> public class AddUserAsync extends AsyncTask&lt;Void,Void,Void&gt; {
      OkHttpClient client=null;
      RequestBody formBody=null;
      Request request=null;
      JSONObject json = null;
      String fromServer = "";
      @Override
      protected void onPreExecute() {
          super.onPreExecute();
          pDialog = new ProgressDialog(UploadImage.this);
          pDialog.setMessage("Creating Account...");
          pDialog.setIndeterminate(false);
          pDialog.setCancelable(false);
          pDialog.show();
      }
      @Override
      protected Void doInBackground(Void... voids) {
          GetUserDetails();
          GenerateGCMID();
          email= email.trim().toLowerCase();
          latitude = GPSTracker.getLatitude();
          longitude =  GPSTracker.getLongitude(); 
          client = new OkHttpClient().newBuilder().readTimeout(30,TimeUnit.SECONDS).connectTimeout(30,TimeUnit.SECONDS).build();
          formBody = new FormBody.Builder()
                  .add("ID",ID)
                  .add("Name",name)
                  .add("email",email)
                  .add("password",password)
                  .add("age",age)
                  .add("number",number)
                  .add("bloodgroup",bloodgroup)
                  .add("lat",latitude+"")
                  .add("longi",longitude+"")
                  .add("image",encodedPhotoString)
                  .build();
          request = new Request.Builder()
                  .url("http://faceblood.website/blood_app/Adduser.php")
                  .post(formBody)
                  .build();
          try {
              Response response = client.newCall(request).execute();
              String res = response.body().string();
              json = new JSONObject(res);
              fromServer = json.getString("added");
              Log.e("stringtest",json.getString("added"));
          } catch (IOException e) {
              Log.e("IOException",e.toString());
              e.printStackTrace();
          } catch (JSONException e) {
              Log.e("JSONException",e.toString());
              e.printStackTrace();
          }      
          return null;
      }
      @Override
      protected void onPostExecute(Void aVoid) {
          super.onPostExecute(aVoid);
          pDialog.dismiss();
  
          Log.e("fromServer",fromServer);
          if(fromServer.equals("addeduser")){
              Toast.makeText(getBaseContext(), "Created Successfully", Toast.LENGTH_LONG).show();
              onSignupSuccess();
          }else {
              Toast.makeText(getBaseContext(), "Network problem. Try again", Toast.LENGTH_LONG).show();
          }
      }
  }
  </code></pre>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  require "conn.php";
  
  $id = $_POST["ID"];
  
  $name = $_POST["Name"];
  
  $email = $_POST["email"];
  
  $password = $_POST["password"];
  
  $age = $_POST["age"];
  
  $number = $_POST["number"];
  
  $blood = $_POST["bloodgroup"];
  
  $latitude = $_POST["lat"];
  
  $longitude = $_POST["longi"];
  
  $image = $_POST["image"];
  
  $splitEmail = explode('@', $email);
  $imageValue = base64_decode($image);
  $image = $splitEmail[0].".jpg";
  $path = "images/".$image;
  file_put_contents($path, $imageValue);
  
  
  $sql = "INSERT INTO UserDetails (ID,Name,email,password,age,number,bloodgroup,lat,longi,image)
  VALUES ('$id','$name','$email','$password','$age','$number','$blood','$latitude','$longitude','$image')"; 
   
  
  
  if ($conn-&gt;query($sql) === TRUE) {
      $response["added"] = "addeduser";
  } else {
  
  }
  
  echo json_encode($response); 
  $conn-&gt;close();
  ?&gt;</code></pre>
  </div>
  </div>
  </p>