Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

Need browser friendly versions of node.js iot modules - client can't connect to iot hub #11

Closed
rricart opened this issue Jan 9, 2017 · 3 comments

Comments

@rricart
Copy link

rricart commented Jan 9, 2017

Trying to implement a device-to-cloud receiver on browser. Console code in "Get started with IoT Hub (Node)" documentation works fine. Encountered following errors on browser:

  1. node module: azure-iot-common -> lib\authorization.js :: runtime error - crypto.createHmac is not a function.
    • we changed reference of crypto to crypto-browserify in this file and installed crypto-browserify node module in root directory, which resolve that error.
  2. After 1 was resolved then we got the following - node module: azure-event-hubs -> node_modules\amqp10\lib\transport\tls_transport.js :: runtime error - tls.connect is not a function.
    • we changed reference of tls to tls-browserify in this file and installed tls-browserify node module in root directory, which resolve the error.
  3. After 2 resolve then we got the following - node module: tls-browserify -> index.js :: runtime error net.Socket is undefined.
    • we changed reference of net to net-browserify and installed the module in root directory, which solved the problem.
  4. Now the while opening the connection at run time we are getting "cannot open TCP connection" error:
    
    let client = Client.fromConnectionString(connectionString);
    client.open() <---- error thrown here
    .then(client.getPartionIds.bind(client)
    .then(function(partitionIds){ .....
    Note: we will then try to implement a simulated device on the browser and must have browser friendly versions of azure-iothub, azure-iot-device, and azure-iot-device-amqp or mqtt
@olivierbloch
Copy link

Hi @rricart , at this point the Azure IoT Hub service doesn't support CORS (Cross-Origin Resources Sharing), which I think will anyways prevent the code running in the browser client to establish the TCP connection with IoT Hub.
This feature is in our plan of record but we don't have an ETA for it yet.
To help out prioritize the feature and help unblock you with an alternative, can you please share what the scenario is that you are trying to implement?
Thanks

@rricart
Copy link
Author

rricart commented Jan 12, 2017 via email

@fbertilsson
Copy link

Hi,

I too, have been struggling with the node libraries in the browser. I abandoned it and decided to try REST which I now find out is not possible.

This would be a great feature. Write a web site and send data to the cloud. I hope this will be possible soon. I believe it would speed up adoption and creativity!

At least, add the CORS support. That should be real quick.

Thanks,
Fredrik

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants