将设备注册到 IoTCentral 的调用会返回异常,但该设备确实会在 Web 应用程序中可见(在未关联的设备下)。
谷歌搜索,找不到任何东西。使用 DEBUG=* 运行,看到了
azure-iot-provisioning-device-http:Http {"operationId":"4.dd5e9d546d057f12.8a2a1010-281f-4ac1-a29f-591800934ecc","status":"failed","registrationState":{"registrationId":"jeffsdeskjune","createdDateTimeUtc":"2019-06-17T14:25:14.7183582Z","status":"failed","errorCode":400209,"errorMessage":"Custom allocation failed with
status code: 401","lastUpdatedDateTimeUtc":"2019-06-17T14:25:14.8832611Z","etag":"IjZkMDBmY2MwLTAwMDAtMDEwMC0wMDAwLTVkMDdhMmNhMDAwMCI="}}
401 将是未经授权的,但这是什么“自定义分配”?缺少的授权是这个试图注册自己的原始设备预期提供的东西,还是某种服务到服务的东西?
代码(Javascript/节点):
var transport = new Transport();
var securityClient = new X509Security(registrationId, deviceCert);
deviceClient = ProvisioningDeviceClient.create(provisioningHost, idScope, transport, securityClient);
// Register the device. Do not force a re-registration.
deviceClient.register(function (err, result) {
if (err) {
console.log("error registering device: " + err);
代码从 azure-iot-sdk-node 中的 register_x509.js 复制。抛出的错误是“错误注册设备:ProvisioningRegistrationFailedError:注册失败”。然而,如果我去 xxx.azureiotcentral.com 设备资源管理器/未关联的设备,该设备确实出现在那里。无论设备已经在该列表中还是我先将其删除,都会引发错误。签署此设备证书的证书已上传并验证,仍然有效。发生了什么/我应该怎么做?