jonas-werner / EdgeX_Tutorial

Repository holding files for EdgeX Foundry tutorial (NOTE: Work in progress as of August 2020)
14 stars 9 forks source link

Connection refused with device PUT command #2

Closed C-monC closed 3 years ago

C-monC commented 3 years ago

Hi,

Thanks for the great tutorial!

I've been working through the document and cannot get past "Issuing commands via EdgeX". I've run the python script to generate the device.

python ./createRESTDevice.py -ip 0.0.0.0 -devip 0.0.0.0
Result for createAddressables: <Response [200]> - Message: 11451015-09c6-40e2-9f70-0ef1a9eb0ae1
Result for createValueDescriptors #1: <Response [200]> - Message: 5d0f8580-81f7-4c23-8500-2f7e9653f64f
Result of uploading device profile: <Response [200]> with message 5c2faab0-a37d-4375-9e02-e62c95c239b1
Result for createDeviceService: <Response [200]> - Message: 3a8b1a26-3aec-477e-9a47-e7659320eca0
Result for addNewDevice: <Response [200]> - Message: 556fb5cc-5025-4d6e-b3c5-68021a945b18

And it appears to be successful. I can also inspect the device using GET http://0.0.0.0:48082/api/v1/device. This returns the proper JSON object.

    "put": {
                    "path": "/api/v1/device/{deviceId}/changeColor",
                    "responses": [
                        {
                            "code": "201",
                            "description": "set the color"
                        },
                        {
                            "code": "503",
                            "description": "service unavailable"
                        }
                    ],
                    "url": "http://edgex-core-command:48082/api/v1/device/556fb5cc-5025-4d6e-b3c5-68021a945b18/command/9b203ad2-fbab-4489-9c23-835bf048b5d2"
                }

But then sending another PUT with the above url (replacing edgex-core-command with 0.0.0.0) returns.

Put http://0.0.0.0:5000/api/v1/device/556fb5cc-5025-4d6e-b3c5-68021a945b18/changeColor: dial tcp 0.0.0.0:5000: connect: connection refused

Do you have an idea of what could be wrong?

jonas-werner commented 3 years ago

Hi Harvey,

I'm happy to hear that the tutorial has been useful.

The 0.0.0.0 address is for when you want a service to listen on all IP addresses. It can't be used when specifying a particular device to communicate with, like the REST device you're creating with the Python script.

Therefore, please only use 0.0.0.0 for the listening services specified in the docker-compose.yml file and only there.

For the script, substitute 0.0.0.0 with the IP of the Ubuntu box you are running EdgeX on. If you're also running the color changer app on the same VM and if we assume the VM IP is "192.168.0.10", the following should work:

python ./createRESTDevice.py -ip 192.168.0.10 -devip 192.168.0.10

I believe this would also work with your other question as well for the dbhost and broker address.

Best regards,

Jonas

On Fri, 5 Feb 2021 at 20:29, Simon Harvey notifications@github.com wrote:

Hi,

Thanks for the great tutorial!

I've been working through the document and cannot get past "Issuing commands via EdgeX". I've run the python script to generate the device.

python ./createRESTDevice.py -ip 0.0.0.0 -devip 0.0.0.0 Result for createAddressables: <Response [200]> - Message: 11451015-09c6-40e2-9f70-0ef1a9eb0ae1 Result for createValueDescriptors #1: <Response [200]> - Message: 5d0f8580-81f7-4c23-8500-2f7e9653f64f Result of uploading device profile: <Response [200]> with message 5c2faab0-a37d-4375-9e02-e62c95c239b1 Result for createDeviceService: <Response [200]> - Message: 3a8b1a26-3aec-477e-9a47-e7659320eca0 Result for addNewDevice: <Response [200]> - Message: 556fb5cc-5025-4d6e-b3c5-68021a945b18

And it appears to be successful. I can also inspect the device using GET http://0.0.0.0:48082/api/v1/device. This returns the proper JSON object.

"put": {
                "path": "/api/v1/device/{deviceId}/changeColor",
                "responses": [
                    {
                        "code": "201",
                        "description": "set the color"
                    },
                    {
                        "code": "503",
                        "description": "service unavailable"
                    }
                ],
                "url": "http://edgex-core-command:48082/api/v1/device/556fb5cc-5025-4d6e-b3c5-68021a945b18/command/9b203ad2-fbab-4489-9c23-835bf048b5d2"
            }

But then sending another PUT with the above url (replacing edgex-core-command with 0.0.0.0) returns.

Put http://0.0.0.0:5000/api/v1/device/556fb5cc-5025-4d6e-b3c5-68021a945b18/changeColor: dial tcp 0.0.0.0:5000: connect: connection refused

Do you have an idea of what could be wrong?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jonas-werner/EdgeX_Tutorial/issues/2, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIRJZSX5FDHVN273AZLEIYTS5PJDNANCNFSM4XETIPUQ .

C-monC commented 3 years ago

Hi Jonas,

Thanks for the help - using 0.0.0.0 was the problem. It also solved the other issue like you said.

I have run into a new issue with grafana but I'll open a new issue so others can also find it.

Kind regards, Simon