"An invalid response was received from the upstream server" when trying to ping

Hello,

I’m trying to import new services in Kong, but I keep getting the same error message (502: Bad Gateway). The service is the EdgeX core_data ping and it works without KONG. It should respond with ‘pong’. The response message says that “An invalid response was received from the upstream server”.

HTTP request:

curl -i -X GET --url http://localhost:8000/ --header ‘Host: coredata.com

This is the service :

{
“host”: “127.0.0.1”,
“created_at”: 1547827284,
“connect_timeout”: 60000,
“id”: “9fbe2306-6eed-4f33-be22-8e51900e043c”,
“protocol”: “http”,
“name”: “core_data_go”,
“read_timeout”: 60000,
“port”: 48080,
“path”: “/api/v1/ping”,
“updated_at”: 1547827284,
“retries”: 5,
“write_timeout”: 60000
}

This is the route to the service:

{
“next”: null,
“data”: [
{
“created_at”: 1547827379,
“methods”: null,
“id”: “ac2a985f-f329-49ed-a280-37b36311efd2”,
“service”: {
“id”: “9fbe2306-6eed-4f33-be22-8e51900e043c”
},
“name”: null,
“hosts”: [
coredata.com
],
“updated_at”: 1547827379,
“preserve_host”: false,
“regex_priority”: 0,
“paths”: null,
“sources”: null,
“destinations”: null,
“snis”: null,
“protocols”: [
“http”,
“https”
],
“strip_path”: true
}
]
}
I think my problem is quite basic and should have an easy solution, but somehow I can’t figure it out. Some help would be really appreciated!

Greetings

Hi,

I faced similar problem as yours on my 1st try with KONG. From your sample response, it seems that you have registered your service with 127.0.0.1. If you have installed KONG as docker, this 127.0.0.1 will point to docker’s 127.0.0.1, not your host machine’s 127.0.0.1. Instead, you have to register your service with your local host machine’s IP address. After this change, it worked for me. Sample response of create service below:

    {
    "host": "10.190.30.222",
    "created_at": 1560770064,
    "connect_timeout": 60000,
    "id": "5ece1209-b68d-4f7d-8737-00068daa25f9",
    "protocol": "http",
    "name": "get-all-orderssss",
    "read_timeout": 60000,
    "port": 9080,
    "path": "/api/orders/",
    "updated_at": 1560770064,
    "retries": 5,
    "write_timeout": 60000,
    "tags": null
 }

Your ping API will work same way with IP address.
http://localhost/api/v1/ping == http://xx.xx.xx.xxx/api/v1/ping

you just need to add host=docker.for.mac.localhost in your kong.yaml thats it

can I see your docker-compose.yml file? If I have 1 kong do reverse_proxy to multiple domain names.