![](/img/trans.png)
[英]Azure IoT Hub device registration via POSTMAN results in Unauthorized
[英]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 issues 。
嘗試使用
client._transport.getReceiver(function (err, rcv) {
作為解決方法
client.getReceiver(function (err, rcv) {
直到他們在庫中修復它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.