您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

常见问题Common Issues

如果你在环境中的 IoT Edge 上使用 Azure 事件网格时遇到问题,请使用本文作为疑难解答和解决方法。If you experience issues using Azure Event Grid on IoT Edge in your environment, use this article as a guide for troubleshooting and resolution.

查看事件网格模块日志View Event Grid module logs

若要解决此问题,你可能需要访问事件网格模块日志。To troubleshoot, you might need to access Event Grid module logs. 为此,请在部署该模块的 VM 上运行以下命令:To do this, on the VM where the module is deployed run the following command:

在 Windows 上,On Windows,

docker -H npipe:////./pipe/iotedge_moby_engine container logs eventgridmodule

在 Linux 上,On Linux,

sudo docker logs eventgridmodule

无法发出 HTTPS 请求Unable to make HTTPS requests

  • 首先确保事件网格模块的 入站: serverAuth: tlsPolicy 设置为 strictenabledFirst make sure Event Grid module has inbound:serverAuth:tlsPolicy set to strict or enabled.

  • 如果其模块到模块的通信,请确保在端口 4438 上进行调用,并且模块的名称与部署的名称相匹配。If its module-to-module communications, make sure that you are making the call on port 4438 and the name of the module matches what is deployed.

    例如,如果事件网格模块是用名称 eventgridmodule 部署的,则 URL 应为 https://eventgridmodule:4438For e.g., if Event Grid module was deployed with name eventgridmodule then your URL should be https://eventgridmodule:4438. 请确保大小写和端口号正确。Make sure casing and port number are correct.

  • 如果它来自非 IoT 模块,请确保在部署期间将事件网格端口映射到主机计算机,例如If it's from non-IoT module, make sure Event Grid port is mapped on to the Host machine during deployment for example,

    "HostConfig": {
                "PortBindings": {
                  "4438/tcp": [
                    {
                        "HostPort": "4438"
                    }
                  ]
                }
     }
    

无法发出 HTTP 请求Unable to make HTTP requests

  • 首先确保事件网格模块的 入站: serverAuth: tlsPolicy 设置为 enableddisabledFirst make sure Event Grid module has inbound:serverAuth:tlsPolicy set to enabled or disabled.

  • 如果其模块到模块的通信,请确保在端口 5888 上进行调用,并且模块的名称与部署的名称相匹配。If its module-to-module communications, make sure that you are making the call on port 5888 and the name of the module matches what is deployed.

    例如,如果事件网格模块是用名称 eventgridmodule 部署的,则 URL 应为 http://eventgridmodule:5888For e.g., if Event Grid module was deployed with name eventgridmodule then your URL should be http://eventgridmodule:5888. 请确保大小写和端口号正确。Make sure casing and port number are correct.

  • 如果它来自非 IoT 模块,请确保在部署期间将事件网格端口映射到主机计算机,例如If it's from non-IoT module, make sure Event Grid port is mapped on to the Host machine during deployment for example,

    "HostConfig": {
                "PortBindings": {
                  "5888/tcp": [
                    {
                        "HostPort": "5888"
                    }
                  ]
                }
    }
    

证书链由不受信任的颁发机构颁发Certificate chain was issued by an authority that's not trusted

默认情况下,事件网格模块配置为使用 IoT Edge security daemon 颁发的证书对客户端进行身份验证。By default, Event Grid module is configured to authenticate clients with certificate issued by the IoT Edge security daemon. 请确保客户端正在提供一个根为此链的证书。Make sure the client is presenting a certificate that is rooted to this chain.

中的IoTSecurityhttps://github.com/Azure/event-grid-iot-edge 演示如何从 IoT Edge 安全守护程序检索证书,并使用该证书来配置传出呼叫。IoTSecurity class in https://github.com/Azure/event-grid-iot-edge shows how to retrieve certificates from IoT Edge Security daemon and use that to configure outgoing calls.

如果它是非生产环境,则可以选择禁用客户端身份验证。If it is non-production environment, you have the option to turn off client authentication. 有关如何执行此操作的详细信息,请参阅 安全性和身份验证Refer to Security and Authentication for details on how to do this.

订阅服务器未收到调试事件Debug Events not received by subscriber

这种情况的典型原因如下:Typical reasons for this are:

  • 此事件从未成功发布。The event was never successfully posted. 将事件发布到事件网格模块时,应收到 200 (确定) 的 HTTP StatusCode。An HTTP StatusCode of 200(OK) should been received on posting an event to Event Grid module.

  • 检查事件订阅以验证:Check the event subscription to verify:

    • 终结点 URL 有效Endpoint URL is valid
    • 订阅中的任何筛选器都不会导致事件 "删除"。Any filters in the subscription are not causing the event to be "dropped".
  • 验证订阅服务器模块是否正在运行Verify if the subscriber module is running

  • 登录到部署了事件网格模块的 VM,并查看其日志。Log on to the VM where Event Grid module is deployed and view its logs.

  • 通过设置 broker: logDeliverySuccess = true 并重新部署事件网格模块并重试请求,打开每个传递日志记录。Turn on per delivery logging by setting broker:logDeliverySuccess=true and redeploying Event Grid module and retrying the request. 启用每个传递的日志记录可能会影响吞吐量和延迟,因此一旦调试完成,我们的建议是将此转换回 broker: logDeliverySuccess = false 并重新部署事件网格模块。Turning on logging per delivery can impact throughput and latency so once debugging is complete our recommendation is to turn this back to broker:logDeliverySuccess=false and redeploying Event Grid module.

  • 通过设置指标来启用指标 : reportertype = console 和重新部署事件网格模块。Turn on metrics by setting metrics:reportertype=console and redeploy Event Grid module. 此后的任何操作都会导致度量值记录在事件网格模块的控制台上,该模块可用于进一步调试。Any operations after that will result in metrics being logged on the console of Event Grid module, which can be used to debug further. 建议仅打开用于调试的度量值,并在完成后通过设置度量值将其关闭 : reportertype = 无 和重新部署事件网格模块。Our recommendation is to turn on metrics only for debugging and once complete to turn it off by setting metrics:reportertype=none and redeploying Event Grid module.

后续步骤Next steps

报告任何问题,有关使用中的 IoT Edge 的事件网格的建议,请参阅 https://github.com/Azure/event-grid-iot-edge/issuesReport any issues, suggestions with using Event Grid on IoT Edge at https://github.com/Azure/event-grid-iot-edge/issues.