How to use the azure-iot-device-mqtt.MqttWs function in azure-iot-device-mqtt

To help you get started, we’ve selected a few azure-iot-device-mqtt examples, based on popular ways it is used in public projects.

github Azure / azure-iot-sdk-node / longhaultests / src / iothub_longhaul.ts View on Github external
const deviceId = 'node-longhaul-sak-' + uuid.v4();
let protocol;

/* tslint:disable:no-var-requires */
switch (process.env.DEVICE_PROTOCOL) {
  case 'amqp':
    protocol = require('azure-iot-device-amqp').Amqp;
  break;
  case 'amqp-ws':
    protocol = require('azure-iot-device-amqp').AmqpWs;
  break;
  case 'mqtt':
    protocol = require('azure-iot-device-mqtt').Mqtt;
  break;
  case 'mqtt-ws':
    protocol = require('azure-iot-device-mqtt').MqttWs;
  break;
  case 'http':
    protocol = require('azure-iot-device-mqtt').Http;
  break;
  default:
    debug('unknown protocol: ' + process.env.DEVICE_PROTOCOL);
    process.exit(ERROR_EXIT_CODE);
}
/* tslint:enable:no-var-requires */

const createDevice = (callback) => {
  debug('creating device: ' + deviceId);
  timeout(registry.create.bind(registry), MAX_CREATE_TIME)({ deviceId: deviceId }, (err, deviceInfo) => {
    if (err) {
      debug('error creating device: ' + deviceId + ':' + err.toString());
      callback(err);
github Azure / azure-iot-sdk-node / edge-e2e / wrapper / nodejs-server-server / glue / glueUtils.js View on Github external
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
'use strict';
/*jshint esversion: 6 */

var respondWithCode = require('../utils/writer').respondWithCode;
var debug = require('debug')('azure-iot-e2e:node')
var Mqtt = require('azure-iot-device-mqtt').Mqtt;
var MqttWs = require('azure-iot-device-mqtt').MqttWs;
var Amqp = require('azure-iot-device-amqp').Amqp;
var AmqpWs = require('azure-iot-device-amqp').AmqpWs;
var Http = require('azure-iot-device-http').Http;

/**
 * return failure to the caller, passing the appropriate information back.
 *
 * @param {function} reject reject function from Promise
 * @param {Error} err error to return
 * @param {string} functionName name of function with failure
 */
var returnFailure = function(reject, err, functionName) {
  var errorText = '';
  if (functionName) {
    errorText = 'failure from ' + functionName + ': ';
  }
github Azure / iothub-diagnostics / iothubtests / index.js View on Github external
function mqttWsTest(deviceConnectionString, done) {
  runTest(deviceConnectionString, require('azure-iot-device-mqtt').MqttWs, 'MQTT/WS', done);
}
github Azure / iothub-explorer / iothub-explorer-simulate-device.js View on Github external
var Protocol;
switch(protocolArg) {
  case 'amqp-ws':
    Protocol = require('azure-iot-device-amqp').AmqpWs;
    break;
  case 'http':
    Protocol = require('azure-iot-device-http').Http;
    break;
  case 'mqtt':
    Protocol = require('azure-iot-device-mqtt').Mqtt;
    if (settleMethod !== 'complete') {
      inputError('Cannot ' + settleMethod + ' messages with MQTT: messages are automatically completed.');
    }
    break;
  case 'mqtt-ws':
    Protocol = require('azure-iot-device-mqtt').MqttWs;
    if (settleMethod !== 'complete') {
      inputError('Cannot ' + settleMethod + ' messages with MQTT: messages are automatically completed.');
    }
    break;
  default:
    Protocol = require('azure-iot-device-amqp').Amqp;
    break;
}

var sendInterval = program.sendInterval || 1000;
var sendCount = program.sendCount || Number.MAX_SAFE_INTEGER;
var receiveCount = program.receiveCount || Number.MAX_SAFE_INTEGER;
var uploadFilePath = program.uploadFile;

var deviceConnectionString;
var deviceId = program.args[0];

azure-iot-device-mqtt

MQTT transport for Azure IoT device SDK

MIT
Latest version published 5 months ago

Package Health Score

84 / 100
Full package analysis

Similar packages