- Más nuevo
- Más votos
- Más comentarios
Gavin_A. Much appreciated. Your suggested link fixed the problem.
For anyone else - the answer is here:
https://aws.amazon.com/premiumsupport/knowledge-center/internet-access-lambda-function/
Hi Greg - thank for getting back to me . I've changed my code to use "AmazonIotDataClient.PublishAsync" as you suggested, and that seems like the sensible thing to do.
Unfortunately, I still have the same fundamental problem. Everything works well when I run locally with the "Mock Lambda Test Tool", but my call to publishAsync “times out” on my Lambda function when I try and run the deployed lambda function. (After about 30 seconds, so plenty long enough to publish).
Out of desperation I've changed my policy to the below, and that didn't help. I've guessing that for some reason there is no IP connectivity between my Lambda function and my MQTT url, but fiddling around with vpc's and endpoints hasn't got me any further.
Policy: { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "iot:", "Resource": "" } ] }
Any ideas ?
Thanks
David
Hi David. I recommend you that do not try to connect to the IoT Core broker from your lambda using an MQTT client. Instead, you can use the Publish HTTPS API of the IoT data plane: https://docs.aws.amazon.com/iot/latest/apireference/API_iotdata_Publish.html . This is the most common way of publishing from a Lambda. Our .Net SDK supports this operation: https://docs.aws.amazon.com/sdkfornet/v3/apidocs/items/IotData/MIotDataPublishAsyncPublishRequestCancellationToken.html.
As HTTP doesn't require a connection to the broker before publishing, you can then delete the iot:Connect
action from the Lambda's policy.
Contenido relevante
- OFICIAL DE AWSActualizada hace 3 años
- OFICIAL DE AWSActualizada hace 2 años
- OFICIAL DE AWSActualizada hace 3 años
Hi David, is your Lambda within a VPC? If so, you can either provide it Internet access or create an IoT VPC endpoint within the VPC.