You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

树莓派3上AWS Greengrass Lambda函数验证失败:未收到MQTT消息求助

Troubleshooting Greengrass Lambda Not Publishing to MQTT on Raspberry Pi 3

Let’s walk through common issues that might be blocking your Lambda from sending messages to the hello/world topic, since you’ve already checked off most of the core setup steps.

1. Verify Lambda Function & Deployment Configuration

First, double-check the basics in your Greengrass group:

  • Confirm your Lambda is set to Run on Greengrass core (not a cloud-only function) in the group’s deployment settings. It’s easy to overlook this toggle when adding the function to the group.
  • Check the Lambda code for typos: Ensure the topic name in the code exactly matches hello/world (MQTT topics are case-sensitive, so Hello/World or hello-world won’t work). Also, confirm the code actually publishes the message—official hello-world examples use the Greengrass SDK to send to the local MQTT broker, which forwards to AWS IoT.
  • Make sure your Lambda package is compatible with Raspberry Pi 3’s ARMv7 architecture. If you built the package on an x86 machine, you might need to cross-compile or use an ARM-optimized Lambda layer to avoid runtime errors.

2. Confirm Greengrass Deployment Succeeded

  • Head to the AWS IoT Greengrass console, navigate to your group, and check the Deployment history. Ensure the latest deployment shows a status of Completed. If it’s stuck or failed, re-deploy the group and watch for errors (network blips or permission issues often cause partial deployments).
  • On your Raspberry Pi, verify the Lambda was synced to the core: Look for your Lambda’s folder in /greengrass/ggc/deployment/lambda/packages/—it should contain your function code and dependencies.

3. Dig Into Lambda & Core Logs for Errors

Skip the system logs for a minute and focus on Lambda-specific logs:

  • Navigate to /greengrass/ggc/var/log/user/<your-lambda-function-name>/ and open the latest log file. Look for errors like missing dependencies, permission denied, or failed MQTT publish calls.
  • Check core system logs for context:
    • GGCore.log: Look for entries about Lambda initialization failures or deployment sync issues.
    • GGShadowManager.log: Check for connectivity problems between the core and AWS IoT.

4. Validate MQTT Subscription Setup

  • Ensure your AWS IoT MQTT client is subscribed to the exact topic hello/world (not hello/# or a misspelled variant). Even a single extra space will prevent messages from showing up.
  • Confirm the MQTT client is connected to the same AWS region as your Greengrass group. Cross-region MQTT connections won’t receive messages from your core.

5. Test Lambda Execution Directly on the Core

If you still don’t see messages, trigger the Lambda manually to isolate the issue:

  1. SSH into your Raspberry Pi and navigate to the Greengrass core directory:
    cd /greengrass/ggc/core
    
  2. Invoke the Lambda with the Greengrass CLI:
    sudo ./greengrass-cli function invoke --function-name <your-lambda-function-name> --payload '{}'
    
  3. Check the Lambda logs right after invoking—if the function runs without errors, the issue might be with MQTT forwarding; if it errors out, you’ll see the root cause in the logs.

You can also verify the Greengrass core’s overall health with:

sudo ./greengrass-cli status

This will show if the core is running and if your Lambda is listed as a deployed function.

6. Check Network & Certificate Permissions

  • Ensure your Raspberry Pi has a stable internet connection and can reach AWS IoT endpoints. Test with:
    ping iot.<your-region>.amazonaws.com
    
  • Verify the certificate and key files in /greengrass/certs have correct permissions:
    • The private key (privkey.pem) should have permissions 600 (only readable by root).
    • The certificate (cert.pem.crt) and root CA (root.ca.pem) should have permissions 644.

内容的提问来源于stack exchange,提问作者ashwal

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 09:05:08