SMTP 오류 코드 및 내용에 관한 표준 설명임.
대략적인 표준은 존재하나, 대부분의 메일 서버들이 표준적인 의미를 준수하지 않음으로 참고만 하고, 해당 메일의 서버 담당자에게 문의 하도록 하자.

SMTP 4XX

메일 교환시에 발생하는 4XX 오류들은 수신 서버의 오류 및 발송 서버의 잘못된 요청 작없 혹은 수신 서버의 스팸정책에 의한 메일 수신 거절, 또는 수신 서버의 일시적인 장애 때문에 발생할 수 있는 일시적인 오류임.

SMTP 421

Service Not Abailable, closing transmission channel.
해당 서버가 정상 작동하지 않기 때문에, 요청한 연결을 거절한다는 내용.

  • 서버가 클라이언트의 접속 자체를 거부하는 경우.
  • 서버가 비정상적인 상황인 경우.
  • 서버에 많은 부하가 있어 일시적으로 접속을 거절한 경우.
  • 서버에서 알 수 없는 오류 발생시.

SMTP 450

Requested action aborted: local error in processing.
수신측 메일 서버의 내부적인 이유로 메일 교환 작업 거절.
대부분 스팸 설정 때문에 거절하는 경우.

  • 제한된 크기보다 메일이 큰 경우.
  • 첨부 파일이 많은 경우.
  • 수신측 서버의 알 수 없는 오류

SMTP 451

Requested action aborted: local error in processing.
수신측 메일 서버의 내부적인 이유로 메일 교환 작업을 거절하는 경우.

  • 수신측 메일 서버의 내부적인 이유노 메일 수신 작업을 거절하는 경우
  • 대부분의 경우는 수신측의 스팸 설정때문에 거절하는 경우
  • 제한된 크기보다 메일이 큰 경우, 첨부 파일가 많은 경우.
  • 수신측 서버의 알수 없는 오류.

SMTP 451

Resources temporarily unavailable. Please try again later.
수신측 메일 서버의 부하로 메일 교환 작업을 일시적으로 거절.

SMTP 452

Requested action not taken: insufficient system storage.
수신측 메일 서버의 내부적인 이유로 메일 교환 작업을 거절.

  • 수신측 메일 서버의 내부적인 이유 때문에, 메일 수신 작업을 거절하는 경우.
  • 수신측의 스팸 설정 때문에 거절하는 경우
  • 한개의 연결에서 너무 많은 RCTP 반복이 수행된 경우
  • 수신측 서버의 알수 없는 오류.
728x90
반응형

'ETC' 카테고리의 다른 글

mixin  (0) 2024.01.10
[PowerShell] 텍스트파일 분리  (0) 2022.03.29
[ETC TIP] Windows 환경에서 Tomcat Log 실시간 보기  (0) 2021.03.15
[조달청/나라장터] iframe 링크 생성  (0) 2021.02.04
대용량 텍스트 파일 읽기  (0) 2020.07.01

성능을 고려한 try-catch 문

try-catch 문을 사용하면 예외 처리는 쉽지만, 에러객체.printStackTrace() 로 출력한 stack 이 시스템의 성능을 저하시킬 수 있다.
따라서 에러객체에서 다음과 같이 필요한 정보만 뽑아서 출력하는게 시스템 성능에 좋다.
어떻게 보면 긴 에러 출력보다는 아래와 같이 필요한 부분만 뽑아 보는게 디버깅에 효율 적 인것 같기도 하고...

        try {
            // 예외가 발생할 수 있는 로직
        } catch (Exception e) {
            StackTraceElement[] ste = e.getStackTrace();
            String className  = ste[0].getClassName();
            String methodName = ste[0].getMethodName();
            int lineNumber = ste[0].getLineNumber();
            String fileName = ste[0].getFileName();
            logger.error(">>> ERROR ON {} <<<", fileName);
            logger.error("{} >> {}() : {}", className, methodName, lineNumber);
            logger.error("MSG : {}", e.getMessage());
            logger.error("CUZ : {}", e.getCause());
        }
728x90
반응형

'Language > Java' 카테고리의 다른 글

[Java] 문자열이 날짜 형식인지 확인하기  (0) 2021.10.18
[Java] Map 반복문  (0) 2020.12.08
[JAVA] 구 버젼 설치  (0) 2020.11.02
[Java] ArrayList Sort  (0) 2020.05.22

pom.xml

pom.xml에 다음과 같은 Dependency를 추가 해 준다.
버전에 따라 지원이 되지 않을 수 있다.

<!-- JSON을 위한 Dependency -->
<dependency>
  <groupId>net.sf.json-lib</groupId>
  <artifactId>json-lib</artifactId>
  <version>2.4</version>
  <classifier>jdk15</classifier>
</dependency>
<dependency>
  <groupId>com.fasterxml.jackson.core</groupId>
  <artifactId>jackson-databind</artifactId>
  <version>2.9.5</version>
</dependency>
<dependency>
  <groupId>org.codehaus.jackson</groupId>
  <artifactId>jackson-mapper-asl</artifactId>
  <version>1.9.13</version>
</dependency>
<dependency>
  <groupId>org.codehaus.jackson</groupId>
  <artifactId>jackson-mapper-asl</artifactId>
  <version>1.9.13</version>
</dependency>
<!-- JSON을 위한 Dependency -->

servlet.xml

servlet.xml 혹은 dispatcher-servlet.xml

<mvc:annotation-driven>
  <mvc:message-converters>
  
  <!-- 
    이 부분은 Controller에서 일반적인 HTML을 리턴하기 위한 설정이다.
    JSON을 리턴하지 않을 경우는 Default 값으로 지정 되어 있기 때문에 설정 할 필요 없지만,
    JSON 리턴과 HTML 리턴을 모두 하려면은 명시적으로 설정 해 줘야 한다.
   -->
    <bean class="org.springframework.http.converter.StringHttpMessageConverter">
      <property name="supportedMediaTypes">
        <list>
          <value>text/html; charset=UTF-8</value>
        </list>
      </property>
    </bean>
    
    <!--
      Controller에서 JSON 리턴시 객체를 변환 해주기 위해서 MessageConverter가 필요하다. 
    -->
    <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
      <property name="supportedMediaTypes">
        <list>
          <value>application/json; charset=UTF-8</value>
        </list>
      </property>
    </bean>
    
  </mvc:message-converters>
</mvc:annotation-driven>

Controller

Controller는
필수적으로 @ResponceBody
권장 사항으로 produces = "application/json; charset=UTF-8" 를 명시 해 준다.
produces 속성은 Response의 Content-Type을 제어한다.

@RequestMapping(
    value = "/reqWaterDepth.do",
    method = RequestMethod.POST,
    produces = "application/json; charset=UTF-8")
@ResponseBody
public Map<String, List<WaterDepthDTO>> reqWaterDepth (
    HttpServletRequest req,
    HttpServletResponse res,
    @RequestParam Map<String, String> area
      ) throws Exception {
  logger.info("\n\tREQ Water Depth . do \n" + area.get("area") + "\n");
  return service.getWaterDepthInRange(area.get("area"));
}

Ajax Request

Request 부분에서는 딱히 설정할 것이 없다.

function getData(area) {
  return new Promise(function(resolve, reject) {
    console.group('drawSurvArea getData');
    area = {
      'area' : area
    };
    //  console.log( area );
    $.ajax({
      type : "POST",
      url : "/reqWaterDepth.do",
      data : area,
      dataType : 'json',
      beforeSend : function(xhr, opts) {
        console.log("before send");
        // when validation is false
        if (false) {
          xhr.abort();
        }
      },
      success : function(res) {
        console.log("SUCCESS");
        console.log(res);
        if (Object.keys(res).length === 0
            && JSON.stringify(res) === JSON.stringify({})) {
          alert('해당 영역에 수심데이터가 없습니다.');
          return;
        } else {
          resolve(res);
        }
      },
      error : function(err) {
        console.log("ERR");
        console.error(err.statusText);
        alert('데이터를 처리 하던중 에러가 발생했습니다.\n' + err.statusText + ' : ' + err.status);
        reject(err);
      }
    });
    console.groupEnd('drawSurvArea getData');
  })
}
getData(area).then(function(data) {
  console.log('THEN')
  console.log(data);
});
728x90
반응형

+ Recent posts