쩨이엠 개발 블로그

[ AWS ] AWSIotException: TOO_MANY_REQUESTS 본문

개발/AWS

[ AWS ] AWSIotException: TOO_MANY_REQUESTS

쩨이엠 2020. 8. 5. 17:38
728x90
반응형

요즘 센서 데이터 입수하는 게이트웨이를 만들고 있는데 가끔씩 연결이 안되어있는 센서를 다시 연결하면 이제까지 보내지 못했던 데이터를 한방에 보내준다 ^^ 고맙기도하지.. 유실은 안되겠네..

하고 로그를 보고있는데 로그가 폭발했다

갑자기 죽죽 올라가길래 뭐지 싶어서 봤더니 ㅎㅎ Exception 발생!

 

com.amazonaws.services.iot.client.AWSIotException: TOO_MANY_REQUESTS
com.amazonaws.services.iot.client.core.AwsIotCompletion.get(AwsIotCompletion.java:213)
com.amazonaws.services.iot.client.shadow.AwsIotDeviceCommand.get(AwsIotDeviceCommand.java:58)
com.amazonaws.services.iot.client.shadow.AwsIotDeviceCommandManager.runCommand(AwsIotDeviceCommandManager.java:135)
com.amazonaws.services.iot.client.shadow.AwsIotDeviceCommandManager.runCommandSync(AwsIotDeviceCommandManager.java:100)
com.amazonaws.services.iot.client.shadow.AbstractAwsIotDevice.get(AbstractAwsIotDevice.java:88)
com.amazonaws.services.iot.client.AWSIotDevice.get(AWSIotDevice.java:280)
com.service.iot.pub.AWSPublisher.publish(AWSPublisher.java:105)
com.service.iot.handler.SensorMessageHandler.send(SensorMessageHandler.java:55)
com.service.iot.handler.SensorMessageHandler.ProcessSensorMessages(SensorMessageHandler.java:40)

 

 

에러 곳을 보니 

 

String deviceInfo = device.get();
if(deviceInfo == null || deviceInfo.length() == 0){
    log.warn(" No device properties ");
    return;
}

 

이런 소스코드가 있었다

shadow 가져오는데 문제가 있는 하다

aws doc shadow 오류 부분을 뒤져보았다 

 

Device Shadow error messages

Error Code Error messages
400 (Bad Request)
  • Invalid JSON
  • Missing required node: state
  • State node must be an object
  • Desired node must be an object
  • Reported node must be an object
  • Invalid version
  • Invalid clientToken
    Note
    A client token that is longer than 64 bytes will cause this response.
  • JSON contains too many levels of nesting; maximum is 6
  • State contains an invalid node
401 (Unauthorized) Unauthorized
403 (Forbidden)

Forbidden

404 (Not Found)
  • Thing not found
  • No shadow exists with name: shadowName
409 (Conflict) Version Conflict
413 (Payload Too Large) The payload exceeds the maximum size allowed
415 (Unsupported Media Type) Unsupported documented encoding; supported encoding is UTF-8
429 (Too Many Requests) The Device Shadow service will generate this error message when there are more than 10 in-flight requests.
500 (Internal Server Error) Internal service failure

 

Too Many Requests 에 관한 내용이 있다!!

 

초당 10 이상의 요청이 오면 429 error code 뱉어낸다고 한다

데이터가 넘어 AWS IoT Core 쪽으로 publish 하는 과정에서 AWSIoTDevice shadow 가져오는 부분이 초당 10 이상 호출이 되어서 것으로 아까 문제가 되었던 소스 부분을 지워서 테스트했더니 더이상 에러가 나지 않았다

728x90
반응형
Comments