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

无法将OPC UA仿真服务器数据经OPC Publisher发送至Azure IoT Hub

问题描述

已在Azure门户创建IoT Hub,添加IoT Edge设备并部署了Edge Hub、Edge Agent及Azure Marketplace中的OPC Publisher模块。OPC Publisher日志显示端点已连接,且已处理11条IoT消息,但IoT Hub的设备到云消息数始终为0。以下是相关配置与日志信息:

OPC Publisher的IoT Edge配置

{
    "Hostname": "OPCPublisher",
    "Cmd": [
        "PkiRootPath=/appdata/pki", 
        "--lf=/appdata/publisher.log", 
        "--pf=/appdata/publishednodes.json",
        "--aa",
        "--di=60",
        "--me=Json",
        "--mm=PubSub"
    ],
    "HostConfig": {
        "Binds": [
            "/c/IoTEdgeMapping:/appdata"
        ]
    }
}

OPC Publisher未使用环境变量,Edge Hub与Edge Agent设置了环境变量upseteamProtocol:AMQPWS。

OPC Publisher诊断日志

DIAGNOSTICS INFORMATION for          :  (OPC Publisher 2.9.0.1)
2023-07-21 13:09:14   # Time                               : 2023-07-21T07:39:14.4554649Z
2023-07-21 13:09:14   # Ingestion duration                 :    00:00:00:48 (dd:hh:mm:ss)
2023-07-21 13:09:14   # Ingress DataChanges (from OPC)     :             10 (All time ~0.21/s; 10 in last 60s ~0.21/s)
2023-07-21 13:09:14   # Ingress EventData (from OPC)       :              0
2023-07-21 13:09:14   # Ingress ValueChanges (from OPC)    :             10 (All time ~0.21/s; 10 in last 60s ~0.21/s)
2023-07-21 13:09:14   # Ingress Events (from OPC)          :              0
2023-07-21 13:09:14   # Ingress BatchBlock buffer size     :              0
2023-07-21 13:09:14   # Encoding Block input/output size   :              0 | 0
2023-07-21 13:09:14   # Encoder Notifications processed    :             10
2023-07-21 13:09:14   # Encoder Notifications dropped      :              0
2023-07-21 13:09:14   # Encoder IoT Messages processed     :             11
2023-07-21 13:09:14   # Encoder avg Notifications/Message  :              1
2023-07-21 13:09:14   # Encoder worst Message split ratio  :              0
2023-07-21 13:09:14   # Encoder avg IoT Message body size  :            480
2023-07-21 13:09:14   # Encoder avg IoT Chunk (4 KB) usage :            0.1
2023-07-21 13:09:14   # Estimated IoT Chunks (4 KB) per day:              0
2023-07-21 13:09:14   # Outgress input buffer count        :              0
2023-07-21 13:09:14   # Outgress input buffer dropped      :              0
2023-07-21 13:09:14   # Outgress IoT message count         :             11 (0.2/s)
2023-07-21 13:09:14   # Connection retries                 :              1
2023-07-21 13:09:14   # Opc endpoint connected?            :           True
2023-07-21 13:09:14   # Monitored Opc nodes succeeded count:              1
2023-07-21 13:09:14   # Monitored Opc nodes failed count   :              0

publishednodes.json配置

[
  {
    "EndpointUrl": "opc.tcp://myipaddress:53530/OPCUA/SimulationServer",
    "UseSecurity": false,
    "OpcNodes": [
      {
        "Id": "i=2258",
        "OpcSamplingInterval": 2000,
        "OpcPublishingInterval": 5000,
        "DisplayName": "Current time"
      }
    ]
  }
]

请问哪里配置有误?如何实现OPC UA服务器→OPC Publisher→IoT Hub的数据传输?


解答

核心问题

问题出在OPC Publisher的消息模式参数配置:你设置了--mm=PubSub,该模式下Publisher会尝试直接通过MQTT协议将消息发送到IoT Hub,而非通过本地Edge Hub转发。但在IoT Edge架构中,模块必须通过Edge Hub传递消息,这样消息才会被IoT Hub的设备到云统计捕获,同时符合Edge的通信规范。

修复步骤

  1. 修改OPC Publisher的IoT Edge配置,将--mm=PubSub替换为--mm=EdgeHub:
    {
        "Hostname": "OPCPublisher",
        "Cmd": [
            "PkiRootPath=/appdata/pki", 
            "--lf=/appdata/publisher.log", 
            "--pf=/appdata/publishednodes.json",
            "--aa",
            "--di=60",
            "--me=Json",
            "--mm=EdgeHub"
        ],
        "HostConfig": {
            "Binds": [
                "/c/IoTEdgeMapping:/appdata"
            ]
        }
    }
    
  2. 确认Edge Hub路由配置:确保默认路由(如FROM /messages/* INTO $upstream)存在,该路由会将所有模块发送的消息转发到IoT Hub。
  3. 重新部署模块:在Azure门户中更新IoT Edge设备的模块配置,等待模块重启生效。

额外检查点

  • 查看Edge Hub日志,确认是否有从OPC Publisher接收消息并转发的记录。
  • 验证IoT Edge设备的连接状态,确保设备能正常与IoT Hub通信。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.15 18:04:51