에 요청을 쓰고, 지금까지 내가 알고 가지고있는 동안 IOException이 모두에 대한도 등요청이 서버에 도달 했습니까? OutputStream에
지금은 성공적으로 URL 연결을 열어 말할 수, 시간을 판독 시간을 연결 데이터를 쓰려면 outputStream을 얻는다.
이제 서버에 데이터를 쓰려고합니다. out.write (requestByte); 그럼 내가 IO30Exception을 받게된다. out.write (requestByte) 그게 무슨 의미인가?
요청이 서버에 도달했는지 여부 여기
try {
out.write(requestByte);
logger.info("API Request sent at : " + sdf.format(new Date()));
out.close();
} catch (IOException e) {
logger.info("Exception while writing request to output stream");
e.printStackTrace();
}
전체 코드입니다 ....
try {
bridgeUrl = new URL(url);
if (connectionTime == null) {
connectionTime = StartupCache.getInstance().getConfigByKey(getUniqueKey(ConfigurationConstant.CONNECTION_TIME_OUT));
//connectionTime = TransactionPersistence.getInstance().getConfigByConfigKey(ConfigurationConstant.CONNECTION_TIME_OUT);
if (connectionTime != null && connectionTime.getConfigValue().trim().length() > 0) {
connectionTimeOutInMilliSec = Integer.valueOf(connectionTime.getConfigValue());
}
}
if (bridgeUrl.getProtocol().equalsIgnoreCase("https")) {
ignoreSslCertificateAuthentication();
httpConn = (HttpsURLConnection) bridgeUrl.openConnection();
} else {
httpConn = (HttpURLConnection) bridgeUrl.openConnection();
}
logger.info("\ Request : "+request+"\n");
request="JsonData="+request;
byte[] requestByte = request.getBytes();
httpConn.setRequestProperty("Content-Length", String.valueOf(requestByte.length));
httpConn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
httpConn.setRequestMethod("POST");
httpConn.setDoOutput(true);
httpConn.setDoInput(true);
httpConn.setConnectTimeout(connectionTimeOutInMilliSec);
httpConn.setReadTimeout(connectionTimeOutInMilliSec);
out = httpConn.getOutputStream();
try {
out.write(requestByte);
logger.info("API Request sent at : " + sdf.format(new Date()));
out.close();
} catch (IOException e) {
logger.info("Exception while writing request to output stream");
e.printStackTrace();
}
}catch(MalformedURLException exMurl){
logger.info(exMurl.getMessage());
throw new ApiRequestPostingException("Exception occured while posting request to server");
}
catch(SocketTimeoutException stout){
logger.error(stout.getMessage());
stout.printStackTrace();
if (httpConn != null) {
logger.info("Closing httpConn in exception blcok of output stream connection....");
httpConn.disconnect();
}
throw new ApiRequestPostingException("Exception occured while posting request to server");
}catch(IOException ioex){
logger.error(ioex.getMessage());
ioex.printStackTrace();
if (httpConn != null) {
logger.info("Closing httpConn in exception blcok of output stream connection....");
httpConn.disconnect();
}
throw new ApiRequestPostingException("Exception occured while posting request to server");
}
IOException을 얻지 않았다고해서 데이터가 서버에 도달했음을 의미하지는 않습니다. –
@ EJP 설명을 가져 주셔서 감사합니다. – ROHIT