Greengrass lambda function making a request to local API runs many times

0

Hi,

I have Greengrass installed on a virtual machine (Ubuntu 16) and have been testing deploying on demand lambda functions to the Greengrass core (using Python 2.7). I've managed to follow all of the tutorials in the docs and I've had success with these. I am now attempting to have the lambda function execute a request to a local API to grab some test data. The local API is a simple Flask application that is currently running on the built-in Flask development server.

The lambda function simply looks like this:

import requests
import greengrasssdk

client = greengrasssdk.client('iot-data')

def lambda_handler(event, context):
        req = requests.get("http://127.0.0.1:5000/test")
        client.publish(topic='greengrass-test', payload=req.text)

The issue I've encountered is that when this lambda function is deployed to Greengrass core on the VM, it seems to be sending multiple of these per second and it seems as though its caught in some sort of loop. I've been doing all of the testing through the console in AWS so when I publish to the 'greengrass-test' topic from the console I see the output of the API request displayed multiple times until I kill the local web server. The incoming requests on the API from the lambda are visible in the local logs and I can see that there's about 10 requests per second.
If I run the single GET request from the lambda as a local python script it works fine and calling any other external API from the lambda works fine too - just when I try to call the local API from the lambda function is where I'm seeing the issue

Does anyone know why this might be happening? Any information would be helpful at this stage as I've debugged it as much as I can with the little knowledge I have with lambda and greengrass.

Thanks.

sdbkly
已提问 5 年前328 查看次数
2 回答
0

Hi sdbkly,

What subscriptions do you have setup for your lambda?
Can you share your group.json file?

Can you share any more logs? https://docs.aws.amazon.com/greengrass/latest/developerguide/gg-troubleshooting.html#troubleshooting-logs

Is your lambda subscribed to greengrass-test?

Thanks,
KR-AWS

AWS
KR-AWS
已回答 5 年前
0

Hi KR-AWS,

I ended up re-installing Greengrass on a new VM and could not reproduce the error - it works as expected now. Marking the question as answered.

Thanks.

sdbkly
已回答 5 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则