Closed anonyle47 closed 4 years ago
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"
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.
Thank you for your help
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.
@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.
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
@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.
Hello,
weichou1229 I send you the screenshot which contains all required steps that you asked.
I noticed three errors:
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)
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
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 : snivinthan77127@gmail.com
You can see here all steps that I did. screen_step.zip
@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.
Hello @weichou1229 ,
I have removed the old data with docker-compose down -v, but I have the same error. Picture 1:
You can see the results of the mqtt docker :
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
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
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?
Hello @Salvocll ,
It depends of the version of your Apache, I have Apache2 and the configuration file is located in /etc/apache2/apache2.conf
@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?
@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.
Hello,
I am trying to follow the doc : https://docs.edgexfoundry.org/Ch-ExamplesAddingMQTTDevice.html in order to test mqtt by sending rand number. However i am block to 6.5.8, i can't execute the put and get command.
Best Regards