Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 通过rabbitmq(amqp协议)从云向设备物联网集线器发送消息面临问题_Php_Azure_Rabbitmq_Azure Storage_Azure Iot Hub - Fatal编程技术网

Php 通过rabbitmq(amqp协议)从云向设备物联网集线器发送消息面临问题

Php 通过rabbitmq(amqp协议)从云向设备物联网集线器发送消息面临问题,php,azure,rabbitmq,azure-storage,azure-iot-hub,Php,Azure,Rabbitmq,Azure Storage,Azure Iot Hub,我想用amqp协议将消息从云发送到设备物联网中心。为此,我在php中使用rabbitmq消息代理。我在localhost上尝试了以下代码: //send.php <?php require_once __DIR__ . '/vendor/autoload.php'; use PhpAmqpLib\Connection\AMQPStreamConnection; use PhpAmqpLib\Message\AMQPMessage; $con

我想用amqp协议将消息从云发送到设备物联网中心。为此,我在php中使用rabbitmq消息代理。我在localhost上尝试了以下代码:

//send.php
    <?php
        require_once __DIR__ . '/vendor/autoload.php';
    use PhpAmqpLib\Connection\AMQPStreamConnection;
    use PhpAmqpLib\Message\AMQPMessage;

    $connection = new AMQPStreamConnection('HUBNAME.azure-devices.net', 5671
    , 'HUBNAME.azure-devices.net/DEVICENAME/?api-version=2018-06-30'
    , 'SharedAccessSignature sr=HUBNAME.azure-devices.net
    &sig=XXXX&se=XXXX&skn=iothubowner');

    $channel = $connection->channel();
    $channel->queue_declare('hello', false, false, false, false);
    $json = '{"id":123, "value":"xyz"}';
    $msg = new AMQPMessage($json);
    $channel->basic_publish($msg, '', 'hello');    
    echo " [x] Sent 'Hello World!'\n";    
    $channel->close();
    $connection->close();
//send.php

您无法使用rabbitmq从IotHub发送云到设备消息

" 您通过面向服务的端点(/messages/devicebound)向设备发送云消息。然后,设备通过特定于设备的端点(/devices/{deviceId}/messages/devicebound)接收消息

为了将每个云到设备消息定位在单个设备上,IoT Hub将设置为/devices/{deviceId}/messages/devicebound。 "

阅读更多


您可以\应该利用Azure IoT Hub服务SDK-请参阅。

您不能使用rabbitmq从IotHub向设备发送云到设备消息

" 您通过面向服务的端点(/messages/devicebound)向设备发送云消息。然后,设备通过特定于设备的端点(/devices/{deviceId}/messages/devicebound)接收消息

为了将每个云到设备消息定位在单个设备上,IoT Hub将设置为/devices/{deviceId}/messages/devicebound。 "

阅读更多


您可以\应该利用Azure IoT Hub服务sdk-请参阅。

谢谢,但此端点看起来像是使用https协议,我了解到,对于IoT消息传递协议,请避免https使用amqp或mqtt,关于sdk,我只能使用php sdk,但在那里不可用,您知道我如何处理amqp以从我的服务器向iot hub发送消息吗?我很困惑,请澄清您是想将消息从您的设备发送到IoTHub(D2C)还是想将消息从IoTHub发送到您的设备(C2D)?ThanksI必须使用我的后端PHP处理来自IoT hub的多个设备,为此,我正在寻找API,该API命令IoT hub通过多个设备发送消息。通过上述方式,我能够处理单个设备,因此我获得了新的选项schedule作业,该作业对我有效,我选择了正确的选项吗?Hi@BunkerBoy jobs确实是Azure IoTHub上受支持的场景-jobs在预定时间对一组设备执行设备双更新和直接方法。谢谢,但是这个端点看起来像是使用https协议,我读到关于iot消息传递避免协议https使用amqp或mqtt,关于sdk,我只能使用php sdk,那里没有,你知道我如何处理amqp从我的服务器向iot hub发送消息吗?我很困惑,请澄清您是想将信息从您的设备发送到IoTHub(D2C)还是想将信息从IoTHub发送到您的设备(C2D)?ThanksI必须使用我的后端PHP处理来自IoT hub的多个设备,为此,我正在寻找API,该API命令IoT hub通过多个设备发送消息。通过上述方式,我能够处理单个设备,因此我获得了新的选项schedule job,这对我来说很有效,我是否选择了正确的选项?Hi@BunkerBoy jobs确实是Azure IoTHub上受支持的场景-jobs在预定时间对一组设备执行设备双更新和直接方法。