web-apps-node-iot-hub-data-visualization error: websocket connection failed

TITAN 46 Reputation points
2022-12-06T13:52:13.97+00:00

Hello,
I'm trying to run my data visualization charts from this doc: https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-live-data-visualization-in-web-apps.
I can see the charts on the web app, but the data from the IoT Device is not shown.
It works locally.

the console on the web app shows the following:
267841-qimage1.png

the Azure web app setting is like that:
267832-qimage2.png

Any other information is needed?

Thank you,
R

Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,116 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,875 questions
{count} votes

4 answers

Sort by: Most helpful
  1. TITAN 46 Reputation points
    2023-02-01T13:20:37.5533333+00:00

    Hi,

    so I tried to follow the steps again, but now I chose the B1 plan for the web app, instead of the free plan - and it works just fine now.

    I don't know why, maybe you could find out why..

    Thank you,

    R

    1 person found this answer helpful.

  2. LeelaRajeshSayana-MSFT 13,456 Reputation points
    2022-12-08T19:45:21.557+00:00

    Hi @TITAN ,

    Greetings! I have followed the steps suggested in the document and could successfully deploy the NodeJS application to Azure Web App. I could load the graph without any issue. Please find the below image for reference.

    268660-screenshot-30.png

    I noticed that your node version says 18.3. I have my local node version as 16.18. Please refer the below image from my windows machine Visual Studio Code terminal

    268736-screenshot-31.png

    When executing step 2 of the section Host Web App in App service I have changed the node version to match what I have in my local. Here is the command I have executed

    az webapp create -n RajNodeJSWebApp -g IoTHubResources -p RajNodeJSWebApp --runtime "node|16LTS" --deployment-local-git   
    

    Since your Node version in 18, you may use the node|18LTS in your case.

    My Web App settings look similar to what you. Please find the below image

    268737-screenshot-32.png

    However, I have noticed that the errors reported in the browser console are around WebSocket connections. Step 4 in the section Host Web App in App service is responsible for enabling WebSocket and Htpps connections on the Web App. I see from the Web App settings image you shared that these options are enabled already. But could you please confirm if you have enabled these options using the CLI commands or through the Azure portal UI.

    I would like to point that step 7 of the section in Host Web App in App service requires you to run the command in Azure CLI from the directory of web-apps-code-iot-hub-data-visualization on your local machine.

    Please try to execute the commands sequentially with the pointers I have mentioned and let me know if you still run into any issues.

    ----------

    Kindly accept answer or upvote if the response is helpful so that it would benefit other community members facing the same issue. I highly appreciate your contribution to the community.


  3. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  4. QuantumCache 20,031 Reputation points
    2023-03-09T23:54:09.82+00:00

    Hello @TITAN,

    Just wanted to follow-up on this issue!

    It's great to hear that you were able to resolve the issue by upgrading to a higher tier plan for your web app. It's possible that the issue was related to resource limitations on the free plan, or that there was a temporary outage on the Azure side.

    However, if the issue occurs again, or if you experience any other issues with the web app or IoT Hub, there are a few things you can try:

    1. Check the Azure status page: Sometimes, Azure services experience issues that can affect your applications. You can check the Azure status page (https://status.azure.com/en-us/status) to see if there are any known issues with the service you're using.
    2. Check the logs: You mentioned that you enabled logging, but didn't see anything there. If the issue occurs again, be sure to check the logs for any error messages or other information that may help you diagnose the issue.
    3. Use a tool like Fiddler or Wireshark to capture network traffic: If the issue is related to network connectivity or communication between your IoT device and the web app, capturing network traffic can help you see what's going on and identify any issues.
    4. Try a different device: If you have access to another IoT device, you can try using it to send data to the IoT Hub and see if the issue persists.
    5. Reach out to Azure support: If you're still experiencing issues, you can reach out to Azure support for assistance. They can help you diagnose the issue and suggest possible solutions.

    I hope this helps!

    0 comments No comments