keijack / python-eureka-client

A eureka client written in python. Support registering your python component to Eureka Server, as well as calling remote services by pulling the the Eureka registry.
MIT License
183 stars 43 forks source link

Eureka client in docker container unexpected behaviour. #85

Closed PFernandezTorres closed 3 months ago

PFernandezTorres commented 3 months ago

Hello! I am trying to deploy my project on aws with docker containers but first I am doing testing on my own computer. When trying to do a request to another service, the request fails. This is my py_eureka_client configuration: `class EurekaConfig:

def __init__(self):
    pass

async def start_eureka(self):
    await eureka_client.init_async(eureka_server=http://localhost:8761/eureka/,
                                   app_name="reader-py-service",
                                   instance_host="reader-py-service",
                                   instance_port=8081,
                                   renewal_interval_in_secs=5)`.

Result request and error: [2024-05-14 18:28:09]-[MainThread]-[eureka_client:905] WARNING: do service /configuration?type=IVA in node [530f8864cf0c:configuration-parameters-service:0] error, use next node. Error: .

I do not know how can this happen if the service is configured correctly with eureka

Eureka services: Screenshot 2024-05-14 at 6 34 13 PM

PFernandezTorres commented 3 months ago

I saw that is using localhost as its registration IP and inside containers that does not work, I have changed it so it uses the container's IP address but it still does not work... The only way I managed to make it work it's outside docker containers. When all microservices are running in local, the service works as expected. It is when deployed to Docker it seems to stop working. Not even when all microservices are in Docker except python service (with host IP) seems to function

PFernandezTorres commented 3 months ago

Solved it. Fastapi was running with host 0.0.0.0 instead of 0.0.0.0