TreeGateway / tree-gateway

This is a full featured and free API Gateway
http://treegateway.com
MIT License
189 stars 42 forks source link

Getting errors when service discovered with consul. #176

Closed gintsgints closed 5 years ago

gintsgints commented 5 years ago

Getting error:

error: [Tree-Gateway] Error occurred while trying to proxy request / from localhost:8000 to undefined (ECONNREFUSED) (https://nodejs.org/api/errors.html#errors_common_system_errors)
2019-05-19T17:16:54.065Z - error: HTTP GET - 502 - /auth (6ms)

As I understund, tree-gateway was not able to retrieve hostname of the service.

Some example of consul usage would be helpful.

There is how I try to setup my environment: https://github.com/cloudhrm/frontend

gintsgints commented 5 years ago

This is a code where service registers to consul: https://github.com/cloudhrm/auth/blob/7d03f00d2e18e5be3857387c49d11daeec0a4613/src/index.ts

gintsgints commented 5 years ago

When I try to debug, function buildServiceDiscoveryMiddleware returns correct hostname:port at:

(req as any).proxyOptions = { target: result };
gintsgints commented 5 years ago

All fine. Problem was with wrong address resolve in docker.