Code Monkey home page Code Monkey logo

web-apps-node-iot-hub-data-visualization's Introduction

page_type languages products name urlFragment description
sample
javascript
html
azure-iot-hub
IoTHub data visualization in web application
web-app-visualization
This repo contains code for a web application, which can read temperature and humidity data from IoT Hub and show the real-time data on a web page.

web-apps-node-iot-hub-data-visualization

This repo contains code for a web application, which can read temperature and humidity data from IoT Hub and show the real-time data in a line chart on the web page.

Browser compatiblity

Browser Verified version
Edge 44
Chrome 76
Firefox 69

This tutorial, also published here, shows how to set up a nodejs website to visualize device data streaming to an Azure IoT Hub using the event hub SDK. In this tutorial, you learn how to:

  • Create an Azure IoT Hub
  • Configure your IoT hub with a device, a consumer group, and use that information for connecting a device and a service application
  • On a website, register for device telemetry and broadcast it over a web socket to attached clients
  • In a web page, display device data in a chart

If you don't have an Azure subscription, create a free account before you begin.

You may follow the manual instructions below, or refer to the Azure CLI notes at the bottom to learn how to automate these steps.

Sign in to the Azure portal

Sign in to the Azure portal.

Create and configure your IoT hub

  1. Create, or select an existing, IoT hub.

    • For Size and Scale, you may use "F1: Free tier".
  2. Select the Settings | Shared access policies menu item, open the service policy, and copy a connection string to be used in later steps.

  3. Select Settings | Built-in endpoints | Events, add a new consumer group (e.g. "monitoring"), and then change focus to save it. Note the name to be used in later steps.

  4. Select IoT devices, create a device, and copy device the connection string.

Send device data

Run the visualization website

Clone this repo. For a quick start, it is recommended to run the site locally, but you may also deploy it to Azure. Follow the corresponding option below.

Inspect the code

Server.js is a service-side script that initializes the web socket and event hub wrapper class, and provides a callback to the event hub for incoming messages to broadcast them to the web socket.

Scripts/event-hub-reader.js is a service-side script that connects to the IoT hub's event hub using the specified connection string and consumer group, extracts the DeviceId and EnqueuedTimeUtc from metadata, and then relays message using the provided callback method.

Public/js/chart-device-data.js is a client-side script that listens on the web socket, keeps track of each DeviceId, and stores the the last 50 points of incoming device data. It then binds the selected device data to the chart object.

Public/index.html handles the UI layout for the web page, and references the necessary scripts for client-side logic.

Run locally

  1. To pass parameters to the website, you may use environment variables or parameters.

    • Open a command prompt or PowerShell terminal and set the environment variables IotHubConnectionString and EventHubConsumerGroup.

      Syntax for Windows command prompt is set key=value, PowerShell is $env:key="value", and Linux shell is export key="value".

    • Or, if you are debugging with VS Code, you can edit the launch.json file and add these values in the env property.

      "env": {
          "NODE_ENV": "local",
          "IotHubConnectionString": "<your IoT hub's connection string>",
          "EventHubConsumerGroup": "<your consumer group name>"
      }
  2. In the same directory as package.json, run npm install to download and install referenced packages.

  3. Run the website one of the following ways:

    • From the command-line (with environment variables set), use npm start
    • In VS Code, press F5 to start debugging
  4. Watch for console output from the website.

  5. If you are debugging, you may set breakpoints in any of the server-side scripts and step through the code to watch the code work.

  6. Open a browser to http://localhost:3000.

Use an Azure App Service

The approach here is to create a website in Azure, configure it to deploy using git where it hosts a remote repo, and push your local branch to that repo.

Note: Do not forget to delete these resources after you are done, to avoid unnecessary charges.

  1. Create a Web App.

    • OS: Windows
    • Publish: Code
    • App Service Plan: choose the cheapest plan (e.g. Dev / Test | F1)
  2. Select Settings | Configuration

    1. Select Application settings and add key/value pairs for:
      • Add IotHubConnectionString and the corresponding value.
      • Add EventHubConsumerGroup and the corresponding value.
    2. Select General settings and turn Web socksets to On.
  3. Select Deployment Options, and configure for a Local Git to deploy your web app.

  4. Push the repo's code to the git repo URL in last step with:

    • In the Overview page, find the Git clone URL, using the App Service build service build provider. Then run the following commands:

      git clone https://github.com/Azure-Samples/web-apps-node-iot-hub-data-visualization.git
      cd web-apps-node-iot-hub-data-visualization
      git remote add webapp <Git clone URL>
      git push webapp master:master
    • When prompted for credentials, select Deployment Center | Deployment Credentials in the Azure portal and use the auto-generated app credentials, or create your own.

  5. After the push and deploy has finished, you can view the page to see the real-time data chart. Find the URL in Overview in the Essentials section.

Troubleshooting

If you encounter any issues with this sample, try the following steps. If you still encounter issues, drop us a note in the Issues tab.

Client issues

  • If a device does not appear in the list, or no graph is being drawn, ensure the sample application is running on your device.

  • In the browser, open the developer tools (in many browsers the F12 key will open it), and find the Console. Look for any warnings or errors printed here.

    • Also, you can debug client-side script in /js/chart-device-data.js.

Local website issues

  • Watch the output in the window where node was launched for console output.

  • Debug the server code, namely server.js and /scripts/event-hub-reader.js.

Azure App Service issues

  • Open Monitoring | Diagnostic logs. Turn Application Logging (File System) to on, Level to Error, and then Save. Then open Log stream.

  • Open Development Tools | Console and validate node and npm versions with node -v and npm -v.

  • If you see an error about not finding a package, you may have run the steps out of order. When the site is deployed (with git push) the app service runs npm install which runs based on the current version of node it has configured. If that is changed in configuration later, you'll need to make a meaningless change to the code and push again.

CLI documentation

In order to automate the steps to deploy to Azure, consider reading the following documentation and using the corresponding commands.

# Initialize these variables: $subscriptionId, $resourceGroupName, $location, $iotHubName, $consumerGroupName, $deviceId, $appServicePlanName, $webAppName, $iotHubConnectionString

# Login and set the specified subscription
az login
az account set -s $subscriptionId

# Create the resource group in the specified location
az group create -n $resourceGroupName --location $location

# Create an IoT Hub, create a consumer group, add a device, and get the device connection string
az iot hub create -n $iotHubName -g $resourceGroupName --location $location --sku S1
az iot hub consumer-group create -n $consumerGroupName --hub-name $iotHubName -g $resourceGroupName

az iot hub show-connection-string -n $iotHubName -g $resourceGroupName

az iot hub device-identity create -d $deviceId --hub-name $iotHubName -g $resourceGroupName
az iot hub device-identity show-connection-string  -d $deviceId --hub-name $iotHubName -g $resourceGroupName

# Create an app service plan and website, then configure website
az appservice plan create -g $resourceGroupName -n $appServicePlanName --sku F1 --location $location
az webapp create -n $webAppName -g $resourceGroupName --plan $appServicePlanName --runtime "node|10.6"
az webapp update -n $webAppName -g $resourceGroupName --https-only true
az webapp config set -n $webAppName -g $resourceGroupName --web-sockets-enabled true
az webapp config appsettings set -n $webAppName -g $resourceGroupName --settings IotHubConnectionString=$iotHubConnectionString EventHubConsumerGroup=$consumerGroupName

# Configure website for deployment
az webapp deployment list-publishing-credentials -n $webAppName -g $resourceGroupName
az webapp deployment source config-local-git -n $webAppName -g $resourceGroupName

# Push code to website
# Note: the URL is based on the previous two commands of output in the format of https://<web site user>:<password>@$webAppName.scm.azurewebsites.net/$webAppName.git
git remote add azure <web app git URL>
git push azure master:master

# Open browser to web site home page
az webapp browse -g $resourceGroupName -n $webAppName

Conclusion

In this tutorial, you learned how to:

  • Create an Azure IoT Hub
  • Configure your IoT hub with a device, a consumer group, and use that information for connecting a device and a service application
  • On a website, register for device telemetry and broadcast it over a web socket to attached clients
  • In a web page, display device data in a chart

Note: remember to delete any Azure resources created during this sample to avoid unnecessary charges.

web-apps-node-iot-hub-data-visualization's People

Contributors

amarzavery avatar dependabot[bot] avatar drwill-ms avatar ericmitt avatar kartben avatar kgremban avatar kpm-at-hfi avatar manohar-rajawat avatar microsoftopensource avatar msftgits avatar otaviobrudden avatar sldragon avatar supernova-eng avatar yuwzho avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

web-apps-node-iot-hub-data-visualization's Issues

AMQP connection issue

Hi,
I'm following the documentation here. However, it only works about 10% of the time. Most of the time the page just receives nothing.

I dig a little bit into the log file. The error message from Azure web-app is following:

 Application has thrown an uncaught exception and is terminated:
TypeError: Cannot read property 'write' of null
    at Object.frames.writeFrame (D:\home\site\wwwroot\node_modules\amqp10\lib\frames.js:54:9)
    at Connection.sendFrame (D:\home\site\wwwroot\node_modules\amqp10\lib\connection.js:333:10)
    at ReceiverLink.Link.attach (D:\home\site\wwwroot\node_modules\amqp10\lib\link.js:108:27)
    at ReceiverLink.Link._attemptReattach (D:\home\site\wwwroot\node_modules\amqp10\lib\link.js:237:8)
    at Timeout._onTimeout (D:\home\site\wwwroot\node_modules\amqp10\lib\link.js:225:10)
    at ontimeout (timers.js:365:14)
    at tryOnTimeout (timers.js:237:5)
    at Timer.listOnTimeout (timers.js:207:5)

The initial google search indicates the problem is coming from AMQP connection. But I couldn't find a working solution to this problem.

Any suggestions?

Thanks,

HTTP Error 500

I followed the tutorial but getting HTTP ERROR 500. On the tutorial page one commenter noted it is because of server.js fails due to passing insufficient parameters to the library.

Any fix for this issue?

node:events:356 throw err; // Unhandled 'error' event

node.js version = v16.1.0
npm version = 7.13.0

When i start the program, the following error occurs:

Using IoT Hub connection string [HostName=BS-Hub.azure-devices.net;SharedAccessKeyName=service;SharedAccessKey=***=]
monitoring
Using event hub consumer group [monitoring]
Listening on 3000.
node:events:356
throw err; // Unhandled 'error' event
^

Error [ERR_UNHANDLED_ERROR]: Unhandled error. ({
_context: Error: Invalid handle 0
at Session._get_link (C:\Users\phili\Documents\Schule\BA\temp4\web-apps-node-iot-hub-data-visualization\node_modules\rhea\lib\session.js:724:15)
at Session.on_detach (C:\Users\phili\Documents\Schule\BA\temp4\web-apps-node-iot-hub-data-visualization\node_modules\rhea\lib\session.js:730:10)
at Connection. [as on_detach] (C:\Users\phili\Documents\Schule\BA\temp4\web-apps-node-iot-hub-data-visualization\node_modules\rhea\lib\connection.js:804:30)
at c.dispatch (C:\Users\phili\Documents\Schule\BA\temp4\web-apps-node-iot-hub-data-visualization\node_modules\rhea\lib\types.js:910:33)
at Transport.read (C:\Users\phili\Documents\Schule\BA\temp4\web-apps-node-iot-hub-data-visualization\node_modules\rhea\lib\transport.js:109:36)
at SaslClient.read (C:\Users\phili\Documents\Schule\BA\temp4\web-apps-node-iot-hub-data-visualization\node_modules\rhea\lib\sasl.js:328:26)
at Connection.input (C:\Users\phili\Documents\Schule\BA\temp4\web-apps-node-iot-hub-data-visualization\node_modules\rhea\lib\connection.js:538:35)
at TLSSocket.emit (node:events:365:28)
at addChunk (node:internal/streams/readable:314:12)
at readableAddChunk (node:internal/streams/readable:289:9),
.......

Does anyone know the problem?

Deploying to azure returns blank screen

I followed the instructions on : https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-live-data-visualization-in-web-apps

The website shows a blank screen and the logs from Kudu produces this, what's wrong?

D:\home\site\wwwroot\node_modules\azure-event-hubs\dist\lib\rhea-promise\connection.js:141
async createSender(options) {
^^^^^^^^^^^^
SyntaxError: Unexpected identifier
at Object.exports.runInThisContext (vm.js:76:16)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object. (D:\home\site\wwwroot\node_modules\azure-event-hubs\dist\lib\rhea-promise\index.js:16:20)
at Module._compile (module.js:570:32)
Application has thrown an uncaught exception and is terminated:

Update application setup to use frozen deps version or migrate docs to support updated Node version

The core dependency used by the sample as of version 0.2.1 was based solely on Promises in the implementation details:

https://github.com/Azure/azure-event-hubs-node/tree/v0.2.1-EH-May2018

In the 0.2.4 version the azure-event-hubs added undocumented use of async/await, which bumbed the minum required version of Node to 7.6:

https://github.com/Azure/azure-event-hubs-node/releases/tag/v0.2.4-EH-July2018
https://github.com/Azure/azure-event-hubs-node/blob/v0.2.4-EH-July2018/client/lib/rhea-promise/connection.ts#L179
Azure/azure-event-hubs-node@d367b2a#diff-f2311358a38bc41bc8d4393e0c733a97R7

so they now compiling to runtime that expects support of async/await.

The problem is the Azure default Node version is 6.9.1, so this sample web app breaks either silently or with not widely known error for most users:
#17
I've became aware of the issue via the IOT MVP list reported by other list member.

The quick fix for this app is:

diff --git a/package.json b/package.json
index 0746253..cb77421 100644
--- a/package.json
+++ b/package.json
@@ -6,7 +6,7 @@
     "start": "node server.js"
   },
   "dependencies": {
-    "azure-event-hubs": "^0.2.1",
+    "azure-event-hubs": "0.2.1",
     "express": "~4.14.1",
     "moment": "^2.17.1",
     "ws": "^2.1.0"

this fill froze the azure-event-hub version. Let me know if you want a hot fix issue that way

Thanks!

Empty Graph

I followed both the readme and the documentation from Microsoft on this tutorial. I have it working perfectly when running on my local machine. My device sends data through the IoT Hub, and express puts the data on the graph in the browser. However, when I move from the local machine into the cloud, I get the webpage to load, but no data is ever displayed in the graph. I can confirm in the dev tools console that the browser's web socket is connected to Azure. There's no additional debugging information provided as to why I'm not receiving data in my browser. I wanted to make sure that my credential were okay (even though it worked locally), so I sshed into Azure Web App and navigated to the public root, duplicated the server, and put it on another port. I could see it receiving the data from the IoT Hub via console messages.

I'm not really sure what's broke since it seems to work both IoT Hub > Express & Express > Browser. Any guidance would be appreciated as the tutorial listed below is a bit out of date with the current Azure app services interface.

Tutorial Followed

Unable to open the amqp connection

I met an error after running 'npm start',

Listening on 3000. Unable to open the amqp connection "connection-1" due to operation timeout.

launch.json is correctly set with the required 'IotHubConnectionString' and 'EventHubConsumerGroup'.
Please advise. Thanks.

Using two resources simultaneously with the same IoT device

I have an Azure account (free trial) and I ran the example following this tutorial : https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-live-data-visualization-in-web-apps, which works fine. I wanted to add a storage account resource in order to save my data using the same IoT device (following https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-store-data-in-azure-table-storage), but when I do, the real time data visualization doesn't work anymore. I can see the data in my container on Microsoft Azure Storage Explorer though.
Isn't it possible to use multiple resources simultaneously with the same IoT device?
Thank you for your help.

no data is shown and an empty local appears

I used the documentation I also see in my cmd;
Using event hub consumer group [myrGroup]
Listening on 3000.
Successfully created the EventHubConsumerClient from IoT Hub event hub-compatible connection string.
The partition ids are: [ '0', '1', '2', '3' ]

But when I open localhost:3000 it is not showing any data

npm v 7.21
node v 14.15

How to port the code for sensors other than temperature and humidity sensors

Hello, I am trying to port the IoT Hub data visualization sample to a flow sensor. There is no porting guide in the readme. I have made some changes in the index.js file in the public directory of the dashboard. I will attach screenshots of the file diff below.
snip20181003_1
snip20181003_2
snip20181003_3
After making only these changes, I am getting errors from the chart.js library. It is an uncaught type error which I do not quite understand. Screenshot below.
snip20181003_4
If I change the code back to temperature, it will start working again. Whenever I try to adapt the code to a different sensor is when I get this error.
Any help would be highly appreciated.
Please let me know if any further clarification or code is required.
Thank you.

Local chart not displayed. Connection closed!

I was in the directory were I clone the project on the console. I run npm install
I'm running the WebApp locally and I get the following message in console after the npm start command:

`> node server.js

Listening on 3000
amqp:connection:forced:The connection was inactive for more than the allowed 60000 milliseconds and is closed by container 'LinkTracker'. TrackingId:eb9b3ad1ee514afb8a321e86e0762586_G0, SystemTracker:gateway2, Timestamp:3/1/2018 6:13:38 PM
^Cnpm ERR! code ELIFECYCLE
npm ERR! errno 3221225786
npm ERR! [email protected] start: `node server.js`
npm ERR! Exit status 3221225786
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Saul\AppData\Roaming\npm-cache\_logs\2018-03-01T19_03_50_749Z-debug.log
^CTerminate batch job (Y/N)? y`

I type localhost:3030 in Chrome and the chart doesn't change.
I go to the Developer Tools of Google and I get the following message:

I open it in Internet Explorer and the same problem.

I kill the server.js and run it again and the same message appear after 1 minute.
I'm running it locally because all my resources of my free trial account dissaper from the portal before 30 days! I'm waiting for technical support. Despite this I know my IoT Hub still exist because I connect to it through the IoT Explorer. My Feather M0 is sending data to IoT Hub (I check with the iothub-explorer monitor utility).

Any idea where is the problem or what I'm doing wrong???

after npm start webSocket.Server fails

D:\home\site\wwwroot\server.js:16
const wss = new WebSocket.Server({ server });
^
SyntaxError: Unexpected token }
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:935:3

npm ERR! [email protected] start: node server.js
npm ERR! Exit status 8
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is most likely a problem with the webapp package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node server.js
npm ERR! You can get their info via:
npm ERR! npm owner ls webapp
npm ERR! There is likely additional logging output above.
npm ERR! System Windows_NT 6.2.9200
npm ERR! command "node" "D:\Program Files (x86)\npm\1.4.28\node_modules\npm\bin\npm-cli.js" "start"
npm ERR! cwd D:\home\site\wwwroot
npm ERR! node -v v0.10.40
npm ERR! npm -v 1.4.28
npm ERR! code ELIFECYCLE

Cannot deploy locally

I followed instructions in README:
-- set Azure.IoT.IoTHub.ConnectionString=
-- set Azure.IoT.IoTHub.ConsumerGroup=

npm install
npm start

and I get error:

> [email protected] start /Users/railsuleymanov/Documents/azure_projects/repos/examples/web-apps-node-iot-hub-data-visualization
> node server.js


/Users/railsuleymanov/Documents/azure_projects/repos/examples/web-apps-node-iot-hub-data-visualization/node_modules/azure-event-hubs/lib/client.js:87
    throw new ArgumentError('Missing argument connectionString');
    ^
ArgumentError: Missing argument connectionString
    at Function.EventHubClient.fromConnectionString (/Users/railsuleymanov/Documents/azure_projects/repos/examples/web-apps-node-iot-hub-data-visualization/node_modules/azure-event-hubs/lib/client.js:87:11)
    at new IoTHubReaderClient (/Users/railsuleymanov/Documents/azure_projects/repos/examples/web-apps-node-iot-hub-data-visualization/IoTHub/iot-hub.js:44:38)
at Object.<anonymous> (/Users/railsuleymanov/Documents/azure_projects/repos/examples/web-apps-node-iot-hub-data-visualization/server.js:32:20)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Function.Module.runMain (module.js:676:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `node server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/railsuleymanov/.npm/_logs/2018-02-07T12_00_21_785Z-debug.log

Use ws protocol instead of wss when deploy to local

By default, when deploy to local environment, we do not use SSL. So,
var ws = new WebSocket('wss://' + location.host);
should be changed to:
var ws = new WebSocket('ws://' + location.host);

Otherwise, the following js error will be throw in browser:
WebSocket connection to 'wss://localhost:3000/' failed: Error in connection establishment: net::ERR_CONNECTION_CLOSED

web app doesn't work with SimulatedTemperatureSensor

Hello,
to get this sample to work with IoT Edge SimulatedTemperatureSensor-Module, I had to change the field access as in PR #40
It prepends .ambient to .temperature and .humidity in the callback function.
This was already added with an earlier PR and overridden by a commit from Sept. 04th 2019.
(e1377fe)

In case this is wanted, just reject my PR and close the issue.

Best regards,
Jan

Web app is out of data relative to data source

The azureiotedge-simulated-temperature-sensor project seems to supply a different data model than this web app is expecting. For example, rather than IotData.temperature existing, there is instead IotData.ambient.temperature and IotData.machine.temperature.

This causes no devices to be listed and no data to be shown.

I don't see where to make a pull request, but /public/js/chart-device-data.js:139-152 should be something like...

      // time and temperature are required
      if (!messageData.MessageDate || !messageData.IotData.ambient.temperature) {
        return;
      }

      // find or add device to list of tracked devices
      const existingDeviceData = trackedDevices.findDevice(messageData.DeviceId);

      if (existingDeviceData) {
        existingDeviceData.addData(messageData.MessageDate, messageData.IotData.ambient.temperature, messageData.IotData.ambient.humidity);
      } else {
        const newDeviceData = new DeviceData(messageData.DeviceId);
        trackedDevices.devices.push(newDeviceData);
        newDeviceData.addData(messageData.MessageDate, messageData.IotData.ambient.temperature, messageData.IotData.ambient.humidity);

With that in place, it works.

Invalid Connection string

I followed exactly the commands.
az iot hub show-connection-string --hub-name IoTHubSmartSafety --policy-name service
shows

This command has been deprecated and will be removed in a future release. Use 'IoT Extension (azure-iot) connection-string command (az iot hub connection-string show)' instead.
{
  "connectionString": "HostName=IoTHubSmartSafety.azure-devices.net;SharedAccessKeyName=service;SharedAccessKey=<key>"
}

I replaced the actual key string with <key>. The connection string does not seem to be working.
npm start

outputs

Using IoT Hub connection string [HostName=IoTHubSmartSafety.azure-devices.net;DeviceId=odroidTemp;SharedAccessKey=<key>]
IoTHubSmartSafetyConsumerGroupOdroid
Using event hub consumer group [IoTHubSmartSafetyConsumerGroupOdroid]
Listening on 3000.
Invalid IotHub connection string.

Node Version: v12.14.1

Deploy to Azure Web Apps Failed!

remote: Copying file: 'public\javascripts\index.js'
remote: Copying file: 'public\javascripts\jquery-2.1.4.min.js'
remote: Copying file: 'public\stylesheets\style.css'
remote: Using start-up script server.js from package.json.
remote: Generated web.config.
remote: The package.json file does not specify node.js engine version constraints.
remote: The node.js application will run with the default node.js version 0.10.40.
remote: Selected npm version 1.4.28
remote: ..
remote: npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.40","npm":"1.4.28"})
remote:
remote: > [email protected] postinstall D:\home\site\wwwroot\node_modules\azure-event-hubs\node_modules\async-lock
remote: >
remote:
remote: npm WARN engine [email protected]: wanted: {"node":">= 4"} (current: {"node":"0.10.40","npm":"1.4.28"})
remote: npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.40","npm":"1.4.28"})
remote: npm WARN engine [email protected]: wanted: {"node":">= 0.12"} (current: {"node":"0.10.40","npm":"1.4.28"})
remote: npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.10.40","npm":"1.4.28"})
remote: .............
remote: npm WARN engine [email protected]: wanted: {"iojs":">= 1.0.0","node":">= 0.12.0"} (current: {"node":"0.10.40","npm":"1.4.28"})
remote: .............
remote: npm ERR! Error: Method Not Allowed
remote: npm ERR! at errorResponse (D:\Program Files (x86)\npm\1.4.28\node_modules\npm\lib\cache\add-named.js:260:10)
remote: npm ERR! at D:\Program Files (x86)\npm\1.4.28\node_modules\npm\lib\cache\add-named.js:203:12
remote: npm ERR! at saved (D:\Program Files (x86)\npm\1.4.28\node_modules\npm\node_modules\npm-registry-client\lib\get.js:167:7)
remote: npm ERR! at Object.oncomplete (fs.js:108:15)
remote: npm ERR! If you need help, you may report this entire log,
remote: npm ERR! including the npm and node versions, at:
remote: npm ERR! http://github.com/npm/npm/issues
remote:
remote: npm ERR! System Windows_NT 6.2.9200
remote: npm ERR! command "D:\Program Files (x86)\nodejs\0.10.40\node.exe" "D:\Program Files (x86)\npm\1.4.28\node_modules\npm\bin\npm-cli.js" "install" "--production"
remote: npm ERR! cwd D:\home\site\wwwroot
remote: npm ERR! node -v v0.10.40
remote: npm ERR! npm -v 1.4.28
remote: npm ERR! code E405
remote: ........
remote: Failed exitCode=1, command="D:\Program Files (x86)\nodejs\0.10.40\node.exe" "D:\Program Files (x86)\npm\1.4.28\node_modules\npm\bin\npm-cli.js" install --production
remote: An error has occurred during web site deployment.
remote:
remote: Error - Changes committed to remote repository but deployment to website failed.
To https://ntmsiotweb.scm.azurewebsites.net:443/ntmsiotweb.git

  • [new branch] master -> master

azure app service does not support websockets.

The recently changed interface for the Azure app service, has no way to configure the application to use Web sockets.
This node.js web application uses web sockets. But since the app service cannot be configured to use web sockets, the application fails.
This app was working fine earlier, before the recently changed app service configuration. Earlier, the web sockets configuration was possible in the "Application settings" page

Web App Not working, messaging entity not found

Until recently, to be precise, this code was working till last week

I use this code to demonstrate IoT webapp but is no more running.
All the steps done and checked multiple times
Deployment node version chosen as (10.14 and 10.6.0) same issue both times.

here's the stream log output
webappUsing event hub consumer group [webapp] (node:6028) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead. Listening on NaN. Successfully created the EventHubConsumerClient from IoT Hub event hub-compatible connection string. The messaging entity 'sb://ihsuprodblres043dednamespace.servicebus.windows.net/amitpihub/$management' could not be found. To know more visit https://aka.ms/sbResourceMgrExceptions. TrackingId:d878531e-d8c9-4ba6-bd9a-171c72d32ce9_G6, SystemTracker:ihsuprodblres043dednamespace.servicebus.windows.net:amitpihub/$management, Timestamp:2020-04-12T06:18:35

[CXP] WebApp not displaying any data

Moving thread here to help fix the issue raised on Docs.
From Customer issue: MicrosoftDocs/azure-docs#53901

Hello,
I'm using an Arduino board to send temperature and humidity data on my Azure Web App.
Everything is working locally, but when migrating to Azure WebApp I have no device to display anymore.
I commented 'return' in chart-device-data.js to make it work locally (as suggested in the issue #52495)
I tried to change the data model (as suggested in issue #37707) but it didn't work.
I've noted that when migrating to Azure, 1 line was automatically deleted: "myLineChart.update();"
Do you know why and if the issue could come from this?
Thank you in advance !

App stops reading messages after a while

I noticed that after some time the app simply stops reading messages (even though devices are still sending messages).

Restarting the app causes messages to be read again.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.