Azure / iot-edge-v1

Azure IoT Edge
http://azure.github.io/iot-edge/
Other
525 stars 257 forks source link

Unable to See Traffic from Realtime Traffic Generator #635

Closed cpatte7372 closed 5 years ago

cpatte7372 commented 5 years ago

Hi Community,

I have successfully deployed my first IoT edge module to a Linux x64 (Ubuntu) device using the following link as a guide https://docs.microsoft.com/en-us/azure/iot-edge/quickstart-linux

The link uses tempSensor to generator realtime streaming data.

I have installed my own realtime stream generator of json data, using the following link http://acesinc.net/introducing-a-streaming-json-data-generator/

The problem is I can see the logs (traffic being generatored) from the tempSensor, however I can't see the traffic being generated from my realtime traffic.

Can someone please explain why I can't see the traffic from my generator, although you can see the traffic from the console screen?

I hope I'm making sense.

Regards

Carlton

cpatte7372 commented 5 years ago

Any thoughts on this issue guys?

aribeironovaes commented 5 years ago

We need more information @cpatte7372 ,

How did you deploy your realtime stream generator to your edge device? Did you connect it to edge hub?

How are you checking the traffic from the realtime stream generator?

It is not clear how you deployment is currently set up.

Let us know,

Angelo Ribeiro.

cpatte7372 commented 5 years ago

@aribeironovaes , thanks for reaching out. I have submitted a number of support tickets with Azure first line engineer, however, they keep on telling me they're waiting to hear from an expert on the subject before they can advise .. its been 7 days since I submitted the ticket and I'm still waiting for help.

Anyway, after that moan, the situation is that I have installed a simple realtime stream generator from the following site.

https://github.com/acesinc/json-data-generator

I installed the generator on my Ubuntu 16.0.4. The generator is now sending events to the machine - the events are something silly like how many times Bruce Lee can do a karate chop..

The Linux machine is installed as as iotedge device - trust me everything is setup correctly in IoTHub (I can send you screenshots if you like).

Now, I would like to know how to send the (Bruce Lee) events to IoT hub..

As regards, checking the traffic ... I can physically see the events appearing on the console when I log in to the Ubuntu machine.

So, the question is, how can I send those events to IoT Hub?

Cheers mate

aribeironovaes commented 5 years ago

Hi @cpatte7372 ,

So, I'm going to assume that when you say "sending data do IoT Hub" you meant to say, through Edge Hub. If you want to send data directly to Iot Hub, you would have to use directly device SDK.

Do send data to edge hub you need to follow this document: https://docs.microsoft.com/en-us/azure/iot-edge/tutorial-csharp-module

This document creates a custom module that receives a message and send it to Edge Hub. On your scenario you would have to modify it to use your data generator and use the module SDK to send data.

Hope this clarifies. Let me know if you have any problems with it.

Thanks,

Angelo Ribeiro.

cpatte7372 commented 5 years ago

@aribeironovaes OMG! I had no idea that is what is required ... how come you were able to tell me that within minutes whereas I'm still waiting to hear from Azure engineer (and I'm paying a lot of money each month for support).

Anyway, I seriously wouldn't know where to start on how to modify the the script to use my data generator. Are you aware of any youtube guides?

I'm really stuck now.

cpatte7372 commented 5 years ago

I just can't see how I can modify it to use my data generator....

aribeironovaes commented 5 years ago

HI @cpatte7372 , I don't know much about the support, but I believe that the support is to address issues you may have on the service side (IotHub, Portal, etc). ON the edge the best place to get questions asked are here in github. (For V2 Actually it's better here: https://github.com/Azure/iotedge/issues).

We always have someone on call and we monitor very close our github issues, so I believe here is the fatest to get issues on edge solved.

Regarding the data generator. What is the language that you are most comfortable? Right now, if I'm not mistaken, we have support with documentation for .NET. If you have a version of the data generator for .NET (on a Nuget package) it would be very easy.

If not, we do have a java client (which I believe has support for modules), but we would to check if they have already good documentation for JAVA (https://github.com/Azure/azure-iot-sdk-java).

With that you can create a module in JAVA, use your data generator (if they have maven package, for example).

So, all depends which language you want to develop your module.

Hope this helps! Let us know,

Angelo Ribeiro

cpatte7372 commented 5 years ago

@aribeironovaes , this is the most ridiculous question, but can you let me how to determine what language the application is written in?

The application is here

https://github.com/acesinc/json-data-generator

cpatte7372 commented 5 years ago

So, I did some research and tried to build a docker image for the iot edge hub device using visual studio code in C#, following the document you provided above.. everything is going fine but when I select 'Build IoT Edge solution' as described in the document I get the following error:

Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\Users\Carlton\Documents\MyFirstModule4\EdgeSolution2> docker build  --rm -f "c:\Users\Carlton\Documents\MyFirstModule4\EdgeSolution2\modules\mycsharpmodule4\Dockerfile.amd64" -t carlscontainer.azurecr.io/mycsharpmodule4:0.0.1-amd64 "c:\Users\Carlton\Documents\MyFirstModule4\EdgeSolution2\modules\mycsharpmodule4" ; if ($?) { docker push carlscontainer.azurecr.io/mycsharpmodule4:0.0.1-amd64 }
Sending build context to Docker daemon  539.1kB
Step 1/12 : FROM microsoft/dotnet:2.0-sdk AS build-env
 ---> 171dea684b3c
Step 2/12 : WORKDIR /app
 ---> Using cache
 ---> f7a8eb2c5fbc
Step 3/12 : COPY *.csproj ./
 ---> Using cache
 ---> 03c27bb0287d
Step 4/12 : RUN dotnet restore
 ---> Running in 4b57f579456a
  Restoring packages for C:\app\mycsharpmodule4.csproj...
C:\Program Files\dotnet\sdk\2.1.200\NuGet.targets(114,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [C:\app\mycsharpmodule4.csproj]
C:\Program Files\dotnet\sdk\2.1.200\NuGet.targets(114,5): error :   An error occurred while sending the request. [C:\app\mycsharpmodule4.csproj]
C:\Program Files\dotnet\sdk\2.1.200\NuGet.targets(114,5): error :   The server name or address could not be resolved [C:\app\mycsharpmodule4.csproj]
The command 'cmd /S /C dotnet restore' returned a non-zero code: 1
PS C:\Users\Carlton\Documents\MyFirstModule4\EdgeSolution2>

Can you let me know if Im on the right track?

cpatte7372 commented 5 years ago

All, just in case it will help, I have attached an image of the error build

aribeironovaes commented 5 years ago

Are you able to build/compile your c# module?

From the error looks like you are having problems to get your nuget packages.

First thing is to make sure your module compiles.

Thanks,

Angelo Ribeiro.

On Tue, Jul 10, 2018 at 9:11 AM, cpatte7372 notifications@github.com wrote:

All, just in case it will help, I have attached an image of the error [image: build] https://user-images.githubusercontent.com/24607961/42522958-53003e8c-8464-11e8-9282-684ad3af5f44.png

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Azure/iot-edge-v1/issues/635#issuecomment-403879671, or mute the thread https://github.com/notifications/unsubscribe-auth/AI75b8l1S0jmIDFLEBRp-C09KhzXKhQHks5uFNJJgaJpZM4VIYOZ .

--

Angelo Ribeiro Msc - Federal University of Pernambuco Team in Training Alumni Triple Crowned! :)

cpatte7372 commented 5 years ago

I believe I've installed all the necessary nuget packages

cpatte7372 commented 5 years ago

Hi, I fixed the nuget issue, now I'm getting the errors:

CSC : error CS5001: Program does not contain a static 'Main' method suitable for an entry point [C:\app\mycsharpmodule4.csproj] The command 'cmd /S /C dotnet publish -c Release -o out' returned a non-zero code: 1

The full output is as follows: The push refers to repository [carlscontainer.azurecr.io/mycsharpmodule4] An image does not exist locally with the tag: carlscontainer.azurecr.io/mycsharpmodule4 PS C:\Users\Carlton\Documents\MyFirstModule4\EdgeSolution2> docker build --rm -f "c:\Users\Carlton\Documents\MyFirstModule4\EdgeSolution2\modules\mycsharpmodule4\Dockerfile.amd64" -t carlscontainer.azurecr.io/mycsharpmodule4:0.0.1-amd64 "c:\Users\Carlton\Documents\MyFirstModule4\EdgeSolution2\modules\mycsharpmodule4" ; if ($?) { docker push carlscontainer.azurecr.io/mycsharpmodule4:0.0.1-amd64 } Sending build context to Docker daemon 539.1kB Step 1/12 : FROM microsoft/dotnet:2.0-sdk AS build-env ---> 171dea684b3c Step 2/12 : WORKDIR /app ---> Using cache ---> f7a8eb2c5fbc Step 3/12 : COPY *.csproj ./ ---> Using cache ---> 03c27bb0287d Step 4/12 : RUN dotnet restore ---> Using cache ---> 74add4c9df90 Step 5/12 : COPY . ./ ---> Using cache ---> f060c00a955b Step 6/12 : RUN dotnet publish -c Release -o out ---> Running in 251fdac1a08c Microsoft (R) Build Engine version 15.7.177.53362 for .NET Core Copyright (C) Microsoft Corporation. All rights reserved.

Restoring packages for C:\app\mycsharpmodule4.csproj... Generating MSBuild file C:\app\obj\mycsharpmodule4.csproj.nuget.g.props. Restore completed in 3.58 sec for C:\app\mycsharpmodule4.csproj. CSC : error CS5001: Program does not contain a static 'Main' method suitable for an entry point [C:\app\mycsharpmodule4.csproj] The command 'cmd /S /C dotnet publish -c Release -o out' returned a non-zero code: 1 PS C:\Users\Carlton\Documents\MyFirstModule4\EdgeSolution2>

Any thoughts?

aribeironovaes commented 5 years ago

HI @cpatte7372 ,

I would recommend you to first make sure your .NET Program can run for them trying to create a docker container. From the error message your Program is missing Main method.

If you want to paste your code.

BTW, this question would be better on Stack overflow. It's more like a coding question than an issue with Edge. Here we address issues with Azure IoT Edge.

Here are some guidelines: "# Need Support?

Let us know,

Angelo Ribeiro.

cpatte7372 commented 5 years ago

Hi, I will post it on Stack Overflow.. in the meantime the code is as follows:

namespace mycsharpmodule4
{
    using System.Collections.Generic;     // for KeyValuePair<>
    using Microsoft.Azure.Devices.Shared; // for TwinCollection
    using Newtonsoft.Json;                // for JsonConvert
    using System;
    using System.IO;
    using System.Runtime.InteropServices;
    using System.Runtime.Loader;
    using System.Security.Cryptography.X509Certificates;
    using System.Text;
    using System.Threading;
    using System.Threading.Tasks;
    using Microsoft.Azure.Devices.Client;
    using Microsoft.Azure.Devices.Client.Transport.Mqtt;

class MessageBody
{
    public Machine machine {get;set;}
    public Ambient ambient {get; set;}
    public string timeCreated {get; set;}
}
class Machine
{
   public double temperature {get; set;}

}
class Ambient
{
   public double temperature {get; set;}
   public int humidity {get; set;}         
}

    }

I will also find out if .NET can be run (although I'm not sure how to determine if it can be run) I'm a real novice trying to find my feet on this. All I want to do is get this work.

Appreciate you hangin there with me on this.

aribeironovaes commented 5 years ago

HI @cpatte7372,

I think I understand what happened. You probably have replaced the entire code on Program .CS by the lines of code on Step 8 of the tutorial: https://docs.microsoft.com/en-us/azure/iot-edge/tutorial-csharp-module

I would start over the tutorial and make sure you follow every steps carefully. I understand that this tutorial is a little tricky, sometimes you have to add code, some times you have to replace code.

Just follow it again very carefully and let us know.

Angelo Ribeiro.

cpatte7372 commented 5 years ago

Hi @aribeironovaes you're totally correct. I think I won't have the knowledge to follow the entire code.. I might just give up

cpatte7372 commented 5 years ago

@aribeironovaes The problem is, the guide you suggested pertains to a simulated device that generates streaming data from tempSensor. Therfore, I don't see how follow that guide step by step.

aribeironovaes commented 5 years ago

Hi @cpatte7372 ,

The guide I sent to you is a sample on how to add your own custom module.

On this case, this module receives a message from tempSensor, changes it and send to iothub. The idea, as I mentioned above, is to change the code for this sample to, instead of sending a message from tempSensor, send from your simulator.

Another way/option for you is to get the source code of temp sensor (https://github.com/Azure/iotedge/tree/master/edge-modules/SimulatedTemperatureSensor), modify it to send data from your generator.

You have multiple options.

Hope this helps,

Angelo Ribeiro.

cpatte7372 commented 5 years ago

@aribeironovaes , thanks for pointing me to source code of the sensor .. I have been searching for that

aribeironovaes commented 5 years ago

You're welcome @cpatte7372 .

Hope everything works well. I'm closing this issue now since it's not an issue with Edge Hub. Feel free to open a new issue if you find any problem with Edge.

Good Luck!

Angelo Ribeiro.