Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const mqtt = require('mqtt');
- const Client = require("ibmiotf");
- const appClientConfig = require('../config').watsonIoTConfigs;
- const rp = require('request-promise');
- let appClient = new Client.IotfApplication(appClientConfig);
- appClient.connect();
- let myClient = new mqtt.connect('tcp://myserver', {
- clientId: 'id222s2',
- username: 'username',
- password: 'password',
- port: 221112,
- will: {
- topic: 'server_disconnected',
- payload: "Server disconnected!, please call technical support",
- qos: 2
- }
- });
- appClient.on("connect", () => {
- console.log('ibmiot connected');
- appClient.subscribeToDeviceStatus();
- appClient.subscribeToDeviceEvents();
- });
- myClient.on('message', function (topic, message) {
- appClient.publish("topic1", "json", 'something') // here the ibmiotf disconnect
- }
Add Comment
Please, Sign In to add comment