本文介绍了面对通过rabbitmq(amqp协议)从云向设备iot集线器发送消息的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
//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();
when i run this send.php
file i am getting error:
fatal error: Uncaught PhpAmqpLib\Exception\AMQPConnectionClosedException: Broken pipe or closed connection in C:\xampp\htdocs\amqp\vendor\php-amqplib\php-amqplib\PhpAmqpLib\Wire\IO\StreamIO.php:222
推荐答案
我们可以看到你在Stack Overflow上问了同样的问题
here 。
We can see that you asked the same question on Stack Overflow here.
我们将继续在那里进行故障排除以及社区的专业知识。
We will continue the troubleshooting there together with the expertise from the community.
谢谢!
这篇关于面对通过rabbitmq(amqp协议)从云向设备iot集线器发送消息的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!