목표 : 노드 모듈 azure-iot-hub을 사용하여 브라우저 (angular2)에서 하늘색 iot 허브 장치를 만듭니다.브라우저에서 IoT 허브 장치를 만들 수 있습니까?
문제 : 브라우저에서 작동하지 않습니다 패키지, 암호화에 따라 달라 푸른-공통 IOT.
단계 다시 : 크롬 도구 콘솔에서
import { Component, OnInit } from '@angular/core';
let iothub = require(‘azure-iothub’);
const connectionString = ‘HostName=<my-host>.azure-devices.net;SharedAccessKeyName=<my-key-name>;SharedAccessKey=<my-key>=’;
@Component({
selector: 'acn-shop',
template: `
<div class="al-main">
<div class="al-content container-fluid">
<h1>Azure IoT Hub Devices</h1>
</div>
</div>`
})
export class ShopComponent implements OnInit {
constructor() {
}
public ngOnInit() {
this.connect();
}
public connect() {
console.log('Calling connect()');
const registry = iothub.Registry.fromConnectionString(connectionString);
}
}
Error: Uncaught (in promise): TypeError: crypto.createHmac is not a function
TypeError: crypto.createHmac is not a function
at Object.hmacHash (authorization.js:36)
at Function.create (shared_access_signature.js:67)
at Object.create (shared_access_signature.js:15)
at Function.fromConnectionString (registry.js:65)
at ShopComponent.Array.concat.ShopComponent.connect (shop.component.ts:32)
… (goes on for a bit) ...
- GitHub의에 비슷한 문제가 있습니다 - https://github.com/ipfs/js-ipfs/issues/270- webcrypto 에 암호화 전환 제안 ,210
잠재적 인 솔루션 : - :
- 가 가지고 스위치 webcrypto -암호화는 푸른--IOT 일반/lib 디렉토리/authorization.js
질문 재 작성 필요 누구든지 노드 모듈 azure-iot-hub을 사용하여 브라우저에서 허브 장치를 만들었습니까?
- 누군가 다른 방법으로 브라우저에서 허브 장치를 만들었습니까?
- Q1,2에 없다면 - 내 잠재적 인 해결책이 실현 가능합니까?
이제 Azure 포털에서 IoT 허브 용 장치를 만들 수 있습니다. Azure IoT 허브 대시 보드로 이동하여 장치 탐색기 메뉴를 엽니 다. – Sneezry