Azure / azure-iot-sdk-node

A Node.js SDK for connecting devices to Microsoft Azure IoT services
https://docs.microsoft.com/en-us/azure/iot-hub/
Other
261 stars 226 forks source link

TypeError: WS.createWebSocketStream is not a function #1170

Closed AiHaibara closed 1 year ago

AiHaibara commented 1 year ago

Context

Description of the issue

pnpm build electron for iotdevice, then running and get error TypeError: WS.createWebSocketStream

Code sample exhibiting the issue

const DeviceClient = require('azure-iot-device').Client;
var Protocol = require('azure-iot-device-mqtt').MqttWs;
this.client = DeviceClient.fromConnectionString(this.connectionString, Protocol);
this.client.open(function (err) {});

Console log of the issue

TypeError: WS.createWebSocketStream is not a function\n at Object.streamBuilder (/Applications/xxx.app/Contents/Resources/app.asar/node_modules/mqtt/lib/connect/ws.js:119:30)\n at MqttClient.wrapper [as streamBuilder] (/Applications/xxx.app/Contents/Resources/app.asar/node_modules/mqtt/lib/connect/index.js:155:36)\n at MqttClient._setupStream (/Applications/xxx.app/Contents/Resources/app.asar/node_modules/mqtt/lib/client.js:415:22)\n at new MqttClient (/Applications/xxx.app/Contents/Resources/app.asar/node_modules/mqtt/lib/client.js:395:8)\n at Object.connect (/Applications/xxx.app/Contents/Resources/app.asar/node_modules/mqtt/lib/connect/index.js:157:18)\n at MqttBase._connectClient (/Applications/xxx.app/Contents/Resources/app.asar/node_modules/azure-iot-mqtt-base/dist/mqtt_base.js:393:46)\n at constructor._onEnter (/Applications/xxx.app/Contents/Resources/app.asar/node_modules/azure-iot-mqtt-base/dist/mqtt_base.js:171:30)\n at constructor.transition (/Applications/xxx.app/Contents/Resources/app.asar/node_modules/machina/lib/machina.js:653:28)\n at constructor.transition (/Applications/xxx.app/Contents/Resources/app.asar/node_modules/machina/lib/machina.js:466:63)\n at constructor.connect (/Applications/xxx.app/Contents/Resources/app.asar/node_modules/azure-iot-mqtt-base/dist/mqtt_base.js:155:54)

anthonyvercolano commented 1 year ago

@AliHaibara Sorry to say the that SDK is not compatible with Electron. Possibility that is could happen in the next 12 months, but no commitment.

AiHaibara commented 1 year ago

@AliHaibara Sorry to say the that SDK is not compatible with Electron. Possibility that is could happen in the next 12 months, but no commitment. azure-iot-device-amqp 1.14.1 is running ok after build.

vishnureddy17 commented 1 year ago

@AiHaibara To clarify, are you saying that you managed to get the SDK working with Electron when using a transport from azure-iot-device-amqp? If so, that is great. However, we don't officially support Electron so we can't provide support on our end for that scenario.

AiHaibara commented 1 year ago

@AiHaibara To clarify, are you saying that you managed to get the SDK working with Electron when using a transport from azure-iot-device-amqp? If so, that is great. However, we don't officially support Electron so we can't provide support on our end for that scenario.

yes, and we will consider to use amqp first, thanks.

vishnureddy17 commented 1 year ago

Glad you have it working. I'm going to go ahead and close this issue since we don't support this scenario. Feel free to leave additional comments/questions to this issue as needed.