2016-02-17 8 views
1

Привет, у меня есть HTTP-запрос, и он отлично работает сегодня, я получил сообщение об ошибкеIOException: javax.net.ssl.SSLHandshakeException: SSL-рукопожатие отменено: ssl = 0xafdb8e00: ошибка ввода-вывода во время системного вызова, сброс соединения с помощью peer

IOException : javax.net.ssl.SSLHandshakeException: SSL handshake aborted: ssl=0xafdb8e00: I/O error during system call, Connection reset by peer 

это, как я сделать запрос, который работал отлично

try { 
     Url = new URL(url); 
     urlConnection = (HttpURLConnection) Url.openConnection(); 
     urlConnection.setRequestMethod("POST"); 
     urlConnection.setUseCaches(false); 
     urlConnection.setConnectTimeout(30000); 
     urlConnection.setReadTimeout(30000); 
     urlConnection.setRequestProperty("Content-Type", "text/xml"); 
     urlConnection.setRequestProperty("Host", "host"); 


     String body = "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"> \n" + 
       " <soap:Body> \n" + 
       xml data 
       " </soap:Body> \n" + 
       " </soap:Envelope>"; 

     System.out.println("the body is " + body); 

     byte[] outputInBytes = body.getBytes("UTF-8"); 

     OutputStream os = urlConnection.getOutputStream(); 

     os.write(outputInBytes); 

     //System.out.println("Message = " + urlConnection.getResponseMessage()); 

     System.out.println(" * 3"); 

     //urlConnection.connect(); 

     if (urlConnection.getResponseCode() == 200) { 
      InputStream in = new BufferedInputStream(urlConnection.getInputStream()); 
      result = IOUtils.toString(in, "UTF-8"); 
      System.out.println("Salik Success is" + result); 

      os.close(); 

      return result; 
     } else { 
      InputStream in = new BufferedInputStream(urlConnection.getErrorStream()); 
      result = IOUtils.toString(in, "UTF-8"); 
      System.out.println("Failure is" + result); 


      os.close(); 

      return null; 
     } 


    } catch (MalformedURLException e) { 
     //e.printStackTrace(); 
     result = "error"; 
     System.out.println("MalformedURLException = " + e.toString()); 
    } catch (IOException e) { 
     //e.printStackTrace(); 
     result = "error"; 
     System.out.println("IOException" + e.toString()); 
    } finally { 
     urlConnection.disconnect(); 
    } 

Любая помощь? С уважением

ответ

0

Это исключение происходит, когда подключение к Интернету медленно или ваше приложение не может подключиться к серверу ..

+0

это правда ??? –