2016-02-17 37 views
1

嘿,我有一個http請求,今天工作正常,我收到一個錯誤IOException:javax.net.ssl.SSLHandshakeException:SSL握手中止:ssl = 0xafdb8e00:系統調用期間發生I/O錯誤,由對端重置連接

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

是真的??? –

相關問題