title: javax.net.ssl.SSLException: SSL handshake aborted on android old devices
body: <p>I have android application that was working fine for most of devices
  Recently some hackers tried to make DDOS attack on our servers that force us to add some security and some firewalls </p>
  
  <p>not some devices are not working and give me the following exception </p>
  
  <pre><code>javax.net.ssl.SSLException: SSL handshake aborted: ssl=0x63eb8240: I/O error during system call, Connection reset by peer 
  </code></pre>
  
  <p>can any one please tell me what is the problem now and how can I solve it ?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>this is the code of my execute method</p>
  
  <pre><code>public static BaseResponse execute(Context context, BaseRequest request) {
  
      mStartTime = System.nanoTime();
  
      BaseResponse response = new BaseResponse();
      DataOutputStream outputStream;
      try {
          URL url = new URL(request.getURL());
          HttpsURLConnection urlConnection = (HttpsURLConnection) url.openConnection();
          urlConnection.setConnectTimeout(TIMEOUT_DURATION);
          urlConnection.setReadTimeout(TIMEOUT_DURATION);
          urlConnection.setRequestMethod(request.getRequestType().getValue());
          urlConnection.addRequestProperty("Accept", "application/json");
          urlConnection.addRequestProperty("Content-Type","application/json");
          urlConnection.setRequestProperty("Accept-Charset", CHARACTER_SET);
          urlConnection.addRequestProperty("Device-Id", PhoneUtils.getDeviceId(context));
          urlConnection.addRequestProperty("Version-Number", PhoneUtils.getAppVersion(context));
  
  
          TLSSocketFactory socketFactory = new TLSSocketFactory();
          urlConnection.setSSLSocketFactory(socketFactory);
  
          switch (request.getRequestType()) {
              case POST:
              case PUT:
                  urlConnection.setDoOutput(true);
                  if (request.getStringEntity() != null) {
                      outputStream = new DataOutputStream(urlConnection.getOutputStream());
                      BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outputStream, CHARACTER_SET));
                      writer.write(request.getStringParam());
                      writer.close();
                      outputStream.flush();
                      outputStream.close();
                  }
  
                  break;
              case GET:
                  urlConnection.setDoOutput(false);
                  break;
          }
  
          urlConnection.connect();
  
          try {
              if (urlConnection.getResponseCode() == STATUS_OK) {
                  InputStream inputStream = new BufferedInputStream(urlConnection.getInputStream());
                  BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
                  StringBuilder result = new StringBuilder();
                  String line;
                  while ((line = reader.readLine()) != null) {
                      result.append(line);
                  }
  
                  inputStream.close();
                  response.setResponse(convertStringToJSONObject(result.toString()));
              } else {
                  response.setResponse(null);
              }
          } catch (Exception ex) {
              response.setAppError(AppError.DATA_ERROR);
          }
      } catch (MalformedURLException e) {
          e.printStackTrace();
          response.setAppError(AppError.PARSING_ERROR);
      } catch (IOException e) {
          e.printStackTrace();
          response.setAppError(AppError.DATA_ERROR);
      } catch (Exception e) {
          e.printStackTrace();
          response.setAppError(AppError.DATA_ERROR);
      }
  
      return response;
  }
  </code></pre>