TypeError:client.getReceiver 不是 azure-iot-device-http 示例中的函数
TypeError: client.getReceiver is not a function in azure-iot-device-http examples
我正在使用azure-iot-device-http,并运行入门代码:
var clientFromConnectionString = require('azure-iot-device-http').clientFromConnectionString;
var Message = require('azure-iot-device').Message;
var connectionString = 'myHostname,myDevice,myKey;
var client = clientFromConnectionString(connectionString);
var msg = new Message('some data from my device');
client.sendEvent(msg, function (err) {
if (err) console.log(err.toString());
});
client.getReceiver(function (err, rcv) {
rcv.on('message', function (msg) {
console.log(msg);
rcv.complete(msg, function () {
console.log('completed');
});
});
rcv.on('errorReceived', function (err) {
console.warn(err);
});
});
但是我收到此错误:
TypeError: client.getReceiver 不是函数
这似乎是库示例中的错误。它看起来不像它定义了client.getReceiver
.你可能应该在这里提交一个错误:github问题。
尝试使用
client._transport.getReceiver(function (err, rcv) {
作为解决方法
client.getReceiver(function (err, rcv) {
直到他们在库中修复它。
相关文章:
- 创建一个类似链接的按钮,并通过Javascript函数打开一个新的弹出窗口
- 将函数的上下文应用于javascript变量
- 如何在JavaScript中将字符串转换为函数引用
- 用嵌套函数和默认函数定义函数
- 使用 jQuery 的 .on 函数如何获取事件的原始元素
- 无法导出函数expressjs/requestjs中的变量
- 函数参数中的数据与指定变量之间的任何性能差异
- JQuery合并了keyup和focusout两个函数
- ES6构造函数返回基类的实例
- 监视函数从服务返回不起作用,但作用域函数起作用
- 我可以在json对象中添加一个函数吗
- AngularJS:我可以跳过函数参数回调吗
- 在 Azure 表存储的插入函数中查询其他表
- TypeError:client.getReceiver 不是 azure-iot-device-http 示例中的函数
- Azure IOT Hub Rest API with Javascript
- azure异步javascript后端等待函数
- Azure Javascript -等待函数完成
- angular$scope在angular控制器中的de函数之外没有值
- 如何在Azure函数的响应中添加自定义http标头
- Azure移动服务- table.read().完成(函数(结果))返回未定义的值