在while内的任何迭代中,都会产生SocketException:连接重置。有人可以给我一些建议吗?
logger.info("Start send xml");
StringBuilder bld = new StringBuilder();
try (Socket socket = new Socket(ipAddress,port)){
socket.setSoTimeout(600000);
OutputStream output = socket.getOutputStream();
PrintWriter writer = new PrintWriter(output, true);
writer.println(xml);
writer.flush();
InputStream input = socket.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(input));
String line;
while ((line = reader.readLine()) != null)
bld.append(line);
writer.close();
reader.close();
} catch (IOException e) {
logger.error("Error sending the XML");
logger.error(e.getMessage());
throw new SendXMLException(e.getMessage());
}
logger.info("End Send xml -> " + bld.toString());
return bld.toString();