This package has been deprecated

Author message:

The Amqp over Websockets feature is now provided by azure-iot-device-amqp.AmqpWs

azure-iot-device-amqp-ws
TypeScript icon, indicating that this package has built-in type declarations

1.0.16 • Public • Published

azure-iot-device-amqp-ws

Communicate with Azure IoT Hub from any device using AMQP over WebSockets.

npm version

Install

npm install -g azure-iot-device-amqp-ws@latest to get the latest (pre-release) version.

Getting Started

Create a device client:

var clientFromConnectionString = require('azure-iot-device-amqp-ws').clientFromConnectionString;
var Message = require('azure-iot-device').Message;
 
var connectionString = '[IoT Hub device connection string]';
 
var client = clientFromConnectionString(connectionString);

Create a callback that sends a message and receives messages. When it receives a message it sends an acknowledgement receipt to the server:

var connectCallback = function (err) {
  if (err) {
    console.error('Could not connect: ' + err);
  } else {
    console.log('Client connected');
    var message = new Message('some data from my device');
    client.sendEvent(message, function (err) {
      if (err) console.log(err.toString());
    });
 
    client.on('message', function (msg) { 
      console.log(msg); 
      client.complete(msg, function () {
        console.log('completed');
      });
    }); 
  }
};

Open the connection and invoke the callback:

client.open(connectCallback);

Readme

Keywords

none

Package Sidebar

Install

npm i azure-iot-device-amqp-ws

Weekly Downloads

33

Version

1.0.16

License

MIT

Last publish

Collaborators

  • windowsazure
  • pierreca