AWS re:Post을(를) 사용하면 다음에 동의하게 됩니다. AWS re:Post 이용 약관

No connection to IoT Core in Docker on an EC2

0

Hello, how are you?

I have an application where IoT devices connect to my topic on IoT Core. I created a device on IoT Core to subscribe to the same topic, receive the messages, and send them to my database through my Node.js/backend environment (I perform some operations on these messages before storing them). When I run my entire application in a Docker container in my local environment, everything works fine: the application connects to IoT Core and receives the messages without any issues.

However, when I deploy my application on an EC2 instance and run the same Docker container, with the same files, certificates, etc., the other parts of the API work normally, but the MQTT connection does not. Even with logs, there is no indication of an error. It seems that the connection to IoT Core does not even start.

Something very strange happens: if I leave the application running in the cloud (even with MQTT not working and not receiving messages) and try to start the application on my computer, MQTT starts a process of closing and reconnecting the connection both in the cloud and locally, and this continues until I stop one of the two applications. When I stop the application on my PC, the application on EC2 starts working correctly, receiving the messages from IoT Core and sending them to the database after processing.

I would like to resolve this issue so that the application works correctly whenever I start the Docker container on EC2, without needing this 'workaround' to make it work.

질문됨 4달 전226회 조회
1개 답변
2

Hi. Each connection needs to use a unique client ID. If two clients use the same client ID, each client connection will cause the other client to disconnect with reason DUPLICATE_CLIENTID: https://docs.aws.amazon.com/iot/latest/developerguide/life-cycle-events.html#connect-disconnect.

It seems that the connection to IoT Core does not even start.

You can confirm in the AWS IoT Core console, or in CloudWatch, whether it's connecting or not.

Please also be aware that a single connection to AWS IoT Core is limited to 100 messages per second (or 512KB per second). I don't know how many devices you have, but your architecture won't scale for a large fleet of devices. I recommend you instead consider to use AWS IoT Core rules engine, and a fan-in pattern: https://iotatlas.net/en/implementations/aws/telemetry/fan-in1/. You might consider to use services such as Amazon SQS or Amazon Kinesis Data Streams to store your incoming messages until your application can consume them: https://iotatlas.net/en/best_practices/aws/data_ingest/#decouple-ingest-from-processing-with-queues-and-streams-1

profile pictureAWS
전문가
답변함 4달 전
profile picture
전문가
검토됨 4달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인