Closed erikwilson closed 6 years ago
@erikwilson
your observations are correct.
As far as service is concerned, CORS is not supported and there's no short-term plan to make this available.
Regarding the SDK, compatibility with browserify never was a goal of the SDK: it is a Node.js SDK, not a generic Javascript SDK. This being said, we're always open to feedback and pull requests. Since it's a sizable chunk of work, if you would like to take it on, I would suggest we talk first about ways to achieve that especially if you want to contribute it back.
What's the scenario that you are trying to build, if I may ask?
The MQTT websocket issue seems to be something other than CORS since there are unofficial examples of MQTT websocket code that are able to connect as a device (https://github.com/azure-iothub/v2).
Right now I am just attempting to setup a virtual device in the browser capable of sending and receiving messages for a broader IOT scenario and would rather not create a service to relay information.
OK, it's a simulator app. That is indeed the most common use case for this request.
Like I said we never structured the SDK to work in the browser. i'm not saying it's not possible, just that we have a lot more stuff on our list of problems to solve that come before that. I'm not against helping with experiments and even taking contributions that would add the feature back into the SDK, but I also need to clearly set expectations: it's unlikely that we'll add this feature ourselves in the short term.
I'm not creating a simulator app, I'm creating a dashboard and a control panel for a real IOT scenario. The person who created that repo also wrote a series of blog posts about using MQTT over websockets through the browser, and created that repo as an example. If you can't support virtual devices in the browser as a feature right now that's okay, we will come up with another solution to the issue. Thanks tho.
Flagging this as wontfix since there's no chance we'll get to that anytime soon and it requires service changes anyway. we may revisit this later.
Is there any alternative for ChromeOS? Would WebAssembly be fine with the C SDK?
@pierreca curious if there's any update? With Blazor out, managing IoT Devices from the Web with the C# SDKs would be sweet.
@timmyreilly The ability to run the sdk in a browser has moved considerably higher in the backlog, but I feel pretty confident that we wouldn't start work on it during the first half of calendar 2020.
Is there anyway of extending HttpTransportSettings class to set the requests' mode?
@anthonyvercolano Is there still a plan to support CORS for the Azure IoT Hub REST services?
Context
Description of the issue:
When attempting to use a browserified version of an azure-iot-device the client is unable to establish a connection. This should be possible as repos like https://github.com/azure-iothub/v2 are capable of connecting MQTT over websockets.
When using a browserified version of azure-iot-device-http the connection is refused due to CORS issues (also see https://github.com/Azure/azure-event-hubs-node/issues/11).
Code sample exhibiting the issue:
Console log of the issue:
For MqttWs and AmqpWs a websocket connection is attempted but fails with:
For Http: