//send.php<?php
require_once __DIR__ .'/vendor/autoload.php';usePhpAmqpLib\Connection\AMQPStreamConnection;usePhpAmqpLib\Message\AMQPMessage;
$connection =newAMQPStreamConnection('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 =newAMQPMessage($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
↧
Facing issue with sending message from cloud to device iot hub via rabbitmq(amqp protocol)
↧