title: Retrofit2 Android increase Timeout connection
body: <p>I'm building a Service to send data throught web services in Android using retrofit2.</p>
  
  <p>Now this is the code:</p>
  
  <pre><code>private void checkUnsyncedRecords() {
  
          final DbLayer db = DatabaseHelper.getDatabase(getApplicationContext(), false);
  
          LinkedList&lt;SensorData&gt; listaDatiUnsunc = db.fetchSensorData(null, false);
  
  
          WebService webService = WebServiceHandler.getService();
  
  
          //endregion
  
          //region Alerts
          if (listaDatiUnsunc.size() &gt; 0) {
  
              JsonArray readAlerts = new GsonBuilder().create().toJsonTree(listaDatiUnsunc).getAsJsonArray();
  
              //create request body
              JsonObject body = WebServiceHandler.getDefaultBody();
              body.addProperty(WebServiceHandler.ID_CLINICAL_DOCUMENT, 70);
              body.add(WebServiceHandler.VALORI, readAlerts);
              //Log.i(TAG, body.toString());
              try {
                  Call&lt;BaseMessage&lt;JsonElement&gt;&gt; request = webService.insertDatiCalza(body);
                  Response&lt;BaseMessage&lt;JsonElement&gt;&gt; response = request.execute();
  
                  if (response.isSuccessful()) {
                      BaseMessage&lt;JsonElement&gt; message = response.body();
                      if (message != null) {
                          if (message.getStatus() == MessageStatus.SUCCESS) {
                              Log.d(TAG, "SensorValue sync succeeded");
  
                              //AGGIORNO LO STATO DI AGGIORNAMENTO DI TUTTE LE RILEVAZIONI
                              for (SensorData sens: listaDatiUnsunc) {
                                  sens.setSync(true);
                                  db.updateSensorData(sens);
                              }
                          } else {
                              Log.e(TAG, "SensorValue sync failed: " + message.getMessage() +
                                      " (code: " + message.getStatus() + ")");
                          }
                      } else {
                          Log.e(TAG, "SensorValue sync: reply message is null.");
                      }
                  } else {
                      Log.e(TAG, "SensorValue sync: request failed (code: " +
                              response.code() + ", body: " + response.message() + ").");
                  }
              } catch (Exception e) {
                  Log.e(TAG, "SensorValue sync call", e);
              } finally {
  
              }
          }
          //endregion
  
  
      }
  </code></pre>
  
  <p>this code works, but sometimes the LinkedList contains more value and I have this exception if it size is big.</p>
  
  <pre><code>java.net.SocketTimeoutException
  </code></pre>
  
  <p>Now there is a way to increase the Timeout connection ?</p>
  
  <blockquote>
    <p>EDIT
    This is the instance of my Retrofit class:</p>
  </blockquote>
  
  <pre><code>public static WebService getService() {
  
          if (webService == null) {
              Gson gson = new GsonBuilder()
                      .setLenient()
                      .create();
              Retrofit retrofit = new Retrofit.Builder()
                      .addConverterFactory(GsonConverterFactory.create(gson)).baseUrl(BASE_URL).build();
              webService = retrofit.create(WebService.class);
          }
  
          return webService;
      }
  </code></pre>