Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
'use strict';
var Protocol = require('azure-iot-device-mqtt').Mqtt;
var ModuleClient = require('azure-iot-device').ModuleClient;
ModuleClient.fromEnvironment(Protocol, function (err, client) {
if (err) {
console.error("Could not create client: " + err.toString());
process.exit(-1);
} else {
console.log('got client');
client.on('error', function (err) {
console.error(err.message);
});
// connect to the edge instance
client.open(function (err) {
if (err) {
console.error('Could not connect: ' + err.message);
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
'use strict';
var ModuleClient = require('azure-iot-device').ModuleClient;
var Protocol = require('azure-iot-device-mqtt').Mqtt;
ModuleClient.fromEnvironment(Protocol, function (err, client) {
if (err) {
console.error("Could not create client: " + err.toString());
process.exit(-1);
} else {
console.log('got client');
client.on('error', function (err) {
console.error(err.message);
});
// connect to the edge instance
client.open(function(err) {
if (err) {
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
'use strict';
var Protocol = require('azure-iot-device-mqtt').Mqtt;
var ModuleClient = require('azure-iot-device').ModuleClient;
var Message = require('azure-iot-device').Message;
ModuleClient.fromEnvironment(Protocol, function (err, client) {
if (err) {
console.error("Could not create client: " + err.toString());
process.exit(-1);
} else {
console.log('got client');
client.on('error', function (err) {
console.error(err.message);
});
client.open(function (err) {
if (err) {
console.error('Could not connect: ' + err.message);
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
'use strict';
var Protocol = require('azure-iot-device-mqtt').Mqtt;
var Client = require('azure-iot-device').ModuleClient;
var Message = require('azure-iot-device').Message;
var fs = require('fs');
var connectionString = process.env.EdgeHubConnectionString;
var client = Client.fromConnectionString(connectionString, Protocol);
console.log('got client');
client.on('error', function (err) {
console.error(err.message);
});
client.setOptions({
ca: fs.readFileSync(process.env.EdgeModuleCACertificateFile).toString('ascii')
}, function(err) {
if (err) {
// 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 ModuleClient = require('azure-iot-device').ModuleClient;
var Message = require('azure-iot-device').Message;
var debug = require('debug')('azure-iot-e2e:node')
var glueUtils = require('./glueUtils');
var NamedObjectCache = require('./NamedObjectCache');
/**
* cache of objects. Used to return object by name to the caller.
*/
var objectCache = new NamedObjectCache();
/**
* Create an event handler which calls the callback for the second event only. Used
* like EventEmitter.Once(), only it returns the second event and then removes itself.
* This is needed for 'properties.desired' events because the first event comes when
* registering for the hander, but in many cases, we want the second event which is
* an actual delta.
'use strict';
var ModuleClient = require('azure-iot-device').ModuleClient;
var Mqtt = require('azure-iot-device-mqtt').Mqtt;
ModuleClient.fromEnvironment(Mqtt, (err, client) => {
if (err) {
console.error(err.toString());
process.exit(-1);
} else {
client.invokeMethod('pierreca-edge-test', 'methodTarget', {
methodName: 'doSomethingInteresting',
payload: 'foo',
responseTimeoutInSeconds: 5,
connectTimeoutInSeconds: 2
}, (err, resp) => {
if (err) {
console.error(err.toString());
process.exit(-1);