Code Monkey home page Code Monkey logo

Comments (15)

weichou1229 avatar weichou1229 commented on July 17, 2024

Did you run the device simulator?
https://docs.edgexfoundry.org/Ch-ExamplesAddingMQTTDevice.html#run-an-mqtt-device-simulator

Did you set up the correct host IP?
The following Host depends on your environment.

# Pre-define Devices
[[DeviceList]]
  Name = "MQ_DEVICE"
  Profile = "Test.Device.MQTT.Profile"
  Description = "General MQTT device"
  Labels = [ "MQTT"]
  [DeviceList.Protocols]
    [DeviceList.Protocols.mqtt]
       Schema = "tcp"
       Host = "192.168.16.68"
       Port = "1883"
       ClientId = "CommandPublisher"
       User = ""
       Password = ""
       Topic = "CommandTopic"

from device-mqtt-go.

anonyle47 avatar anonyle47 commented on July 17, 2024

Hello,
Thanks for your response, I use the correct host (broker ip address) as you can see in the zip file, which contains the configuration, the profile and the docker-compose file.

mqtt.zip

Thank you for your help

from device-mqtt-go.

anonyle47 avatar anonyle47 commented on July 17, 2024

PS: In the Zip file i don't include the ClientID but i tried with the clientID provided by the doc and it's not working.

from device-mqtt-go.

weichou1229 avatar weichou1229 commented on July 17, 2024

@anonyle47
The MQTT device simulator should subscribe to the CommandTopic to receive the request and return the response to the ResponseTopic but it not work after you modified it.

I tried to copy and paste the original content from the document and then it works fine.

image

from device-mqtt-go.

anonyle47 avatar anonyle47 commented on July 17, 2024

Hello @weichou1229 ,

I tried with the js script provided by the doc , but it's not working because the function publish, subscribe and schedule is not recognized. Also, in the js script provided by the doc "method": "get" is not added so i add to the script and I launched the mock-device.js with node. After this modification i had the result observe in the first post.

Now i retry to launch the mock-device.js with the docker but in the device-mqtt application, i don't see the randnumbers sended by the mock-device.js. And when i try to do a PUT command, I have the error : Handler - execReadCmd: error for Device: MQ_DEVICE cmd: testrandnum, can not fetch command response: method=get cmd=randnum /api/v1/device/affede12-44c2-4dba-bda8-42a68a372b06/testrandnum

Thank you for your help

from device-mqtt-go.

weichou1229 avatar weichou1229 commented on July 17, 2024

@anonyle47
Could you provide the detail steps which contains HTTP request content and terminal command? Then I can reproduce the issue to help you identify the problem.

from device-mqtt-go.

anonyle47 avatar anonyle47 commented on July 17, 2024

Hello,

weichou1229 I send you the screenshot which contains all required steps that you asked.

I noticed three errors:

  • The first one linked with js (function not definied)
  • The URL (created by edgex for the command) seems not generated at each execution
  • A problem linked with registration, it seems the previous configuration with the wrong ip address of the broker are used ( I modified the docker-compose.yaml by removing the line 463 that is related to registry). After removed it, I noticed that the configuration used is correct and it takes the valid ip address which is 172.18.0.1 (you can see that in this picture below)

device mqtt without registry

On the other hand, When I run curl -X PUT -d '{"message":"Hello!"}' http://172.18.0.1:48082/api/v1/device/291674cb-d8d0-4b2a-bf45-00f23be9dc7a/command/726eeb1c-c487-4fa6-9984-51540a00a5db directly another ip address is generated which is 172.19.0.1
(you can see that in this picture below)

error_put_get_command

I used the new IP 172.19.0.1 in the curl command curl -X PUT -d '{"message":"Hello!"}' http://172.19.0.1:48082/api/v1/device/291674cb-d8d0-4b2a-bf45-00f23be9dc7a/command/726eeb1c-c487-4fa6-9984-51540a00a5db , I saw this error below

GET_PUT_not_work

Could you help me to know why the next IP is generated knowing that in local my IP is 172.18.0.1, which it isn't normal ?
Another question I could not use GET and PUT commands using edgex's URLS.

Thank you so much.
(I don't know if we can use teamviewer or another App in orde to access my pc remotly. If yes I'll send you all infos)

My email : [email protected]

You can see here all steps that I did.
screen_step.zip

from device-mqtt-go.

weichou1229 avatar weichou1229 commented on July 17, 2024

@anonyle47

The first one linked with js (function not definied)

You should use mqtt-scripts to run the mock-device.js, the docker image already warp the js lib.

The URL (created by edgex for the command) seems not generated at each execution

Sorry, I don't know what you mean.

A problem linked with registration, it seems the previous configuration with the wrong ip address of the broker are used ( I modified the docker-compose.yaml by removing the line 463 that is related to registry). After removed it, I noticed that the configuration used is correct and it takes the valid ip address which is 172.18.0.1 (you can see that in this picture below)

This config will create a device entity. If you want to modify it, you should remove the device entity and restart the device service, or you could just shout down services and remove the old data with command docker-compose down -v

# Pre-define Devices
[[DeviceList]]
  Name = "MQ_DEVICE"
  Profile = "Test.Device.MQTT.Profile"
  Description = "General MQTT device"
  Labels = [ "MQTT"]
  [DeviceList.Protocols]
    [DeviceList.Protocols.mqtt]
       Schema = "tcp"
       Host = "192.168.16.68"
       Port = "1883"
       ClientId = "CommandPublisher"
       User = ""
       Password = ""
       Topic = "CommandTopic"
  [[DeviceList.AutoEvents]]
    Frequency = "30s"
    OnChange = false
    Resource = "testrandnum"

So I thought you just use the wrong IP in your configuration, please remove the old data and setup the IP correctly and then restart the service.

from device-mqtt-go.

anonyle47 avatar anonyle47 commented on July 17, 2024

Hello @weichou1229 ,

I have removed the old data with docker-compose down -v, but I have the same error.
Picture 1:
error_screen

You can see the results of the mqtt docker :
docker-compose-devicemqtt1

docker-compose-devicemqtt2

In fact, I don't know why, the mqtt-script container doesn't send the randnum. I used the python script of issues #114 and I have the same error as it mentioned in the first picture. I don't understand this error.

Also, I have another question about the registry process when I use this command :
curl http://localhost:48071/api/v1/registration -X POST -s -S -d @- <<EOF
{
"name":"MQTT_DEVICE",
"addressable":{
"name":"broker",
"protocol":"tcp",
"address":"172.19.0.1",
"port":1883,
"publisher":"IncomingDataSubscriber",
"user":"",
"password":"",
"topic":"DataTopic"
},
"format":"JSON",
"encryption":{
"encryptionAlgorithm":"",
"encryptionKey":"",
"initializingVector":""
},
"enable":true,
"destination":"MQTT_TOPIC"
}

This command isn't included in the part 6.5 MQTT . I tested it but it doesn't work , I see the same error as it mentioned in the picture 1.
Could you help me to find the solution?
Thank you for your help

from device-mqtt-go.

anonyle47 avatar anonyle47 commented on July 17, 2024

Hello @weichou1229 ,
I resolved the problem, the command put and get wasn't functional due to the configuration in Apache. It's necessary to configure the file apache2.conf in <var/www> the parameter Allow override is set to none and it must be set to All.

Thank you for your help

from device-mqtt-go.

mordredz avatar mordredz commented on July 17, 2024

Hi @anonyle47,

I'm glad you solved the error, but the file in question you talk about where it's located? In the device service container?

Could you give me more information?

from device-mqtt-go.

anonyle47 avatar anonyle47 commented on July 17, 2024

Hello @Salvocll ,

It depends of the version of your Apache, I have Apache2 and the configuration file is located in /etc/apache2/apache2.conf

from device-mqtt-go.

mordredz avatar mordredz commented on July 17, 2024

@anonyle47 , but it is not named apache2 anywhere in the EdgeX guide.. how can it affect the operation of the commands to the device service?

from device-mqtt-go.

anonyle47 avatar anonyle47 commented on July 17, 2024

@Salvocll , when I tried to do the command get or put I realised thanks to postman that my error was linked to the error 500. And when I google that error I realised that the error is linked with Apache. This error is related with the permission.

from device-mqtt-go.

anonyle47 avatar anonyle47 commented on July 17, 2024

@Salvocll https://www.ionos.com/community/server-cloud-infrastructure/apache/how-to-fix-http-error-code-500-internal-server-error/

from device-mqtt-go.

Related Issues (20)

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.