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
184 stars 43 forks source link

Django App is not able to register in Eureka Service Registry #27

Closed RamanPndy closed 4 years ago

RamanPndy commented 4 years ago

Hi,

I've created a Django application which must be registered with the Eureka Service. I've also dockerized Django application and Eureka application and deploying through docker-compose.

I've given name discovery to the eureka service. but as soon as Django application tries itself to register with discovery(Eureka) service it shows the following errors:

Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/py_eureka_client/eureka_client.py", line 705, in register self.try_all_eureka_server(lambda url: _register(url, self.instance)) File "/usr/local/lib/python3.8/site-packages/py_eureka_client/eureka_client.py", line 657, in try_all_eureka_server raise http_client.URLError("All eureka servers are down!") urllib.error.URLError: <urlopen error All eureka servers are down!> [2020-07-13 18:38:13]-[EurekaClient]-[line:647] -WARNING: Eureka server [http://discovery:8761/eureka] is down, use next url to try. 2020-07-13 18:38:13,649 - EurekaClient - WARNING - Eureka server [http://discovery:8761/eureka] is down, use next url to try. [2020-07-13 18:38:13]-[EurekaClient]-[line:725] -ERROR: Error! 2020-07-13 18:38:13,650 - EurekaClient - ERROR - Error! Traceback (most recent call last): Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/py_eureka_client/eureka_client.py", line 721, in send_heart_beat File "/usr/local/lib/python3.8/site-packages/py_eureka_client/eureka_client.py", line 721, in send_heart_beat self.try_all_eureka_server(lambda url: send_heart_beat(url, self.instance["app"], self.try_all_eureka_server(lambda url: send_heart_beat(url, self.instance["app"], File "/usr/local/lib/python3.8/site-packages/py_eureka_client/eureka_client.py", line 657, in try_all_eureka_server File "/usr/local/lib/python3.8/site-packages/py_eureka_client/eureka_client.py", line 657, in try_all_eureka_server raise http_client.URLError("All eureka servers are down!") raise http_client.URLError("All eureka servers are down!") urllib.error.URLError: <urlopen error All eureka servers are down!> urllib.error.URLError: <urlopen error All eureka servers are down!> 2020-07-13 18:38:13,650 - EurekaClient - INFO - Cannot send heartbeat to server, try to register [2020-07-13 18:38:13]-[EurekaClient]-[line:726] -INFO: Cannot send heartbeat to server, try to register [2020-07-13 18:38:13]-[EurekaClient]-[line:647] -WARNING: Eureka server [http://discovery:8761/eureka] is down, use next url to try. 2020-07-13 18:38:13,651 - EurekaClient - WARNING - Eureka server [http://discovery:8761/eureka] is down, use next url to try. [2020-07-13 18:38:13]-[EurekaClient]-[line:707] -ERROR: error! 2020-07-13 18:38:13,651 - EurekaClient - ERROR - error! Traceback (most recent call last): Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/py_eureka_client/eureka_client.py", line 721, in send_heart_beat File "/usr/local/lib/python3.8/site-packages/py_eureka_client/eureka_client.py", line 721, in send_heart_beat self.try_all_eureka_server(lambda url: send_heart_beat(url, self.instance["app"], self.try_all_eureka_server(lambda url: send_heart_beat(url, self.__instance["app"], File "/usr/local/lib/python3.8/site-packages/py_eureka_client/eureka_client.py", line 657, in try_all_eureka_server File "/usr/local/lib/python3.8/site-packages/py_eureka_client/eureka_client.py", line 657, in try_all_eureka_server raise http_client.URLError("All eureka servers are down!") urllib.error.URLError: <urlopen error All eureka servers are down!>

Discovery (Eureka) Service is running on port 8761.

Please help me solving this issue or let me know if you require any further details.

dinuta commented 4 years ago

Hi man,

Depends on the eureka server you use. Some uses http://discovery:8761/eureka and others uses http://discovery:8080/eureka/v2

You can try with an updated eureka server dockerized by me and tested and see if works:

https://github.com/dinuta/netflixoss-eureka

There you have also docker-compose example.

Also there are times when the routing does not go through properly between docker world and your host network. You can restart your PC and try again.

dinuta commented 4 years ago

And also don't forget to add 15 second delay for the proper eureka boot. Generally it boots in 12 seconds.

If the eureka is not up when your service tries to register, there you go :)

RamanPndy commented 4 years ago

@dinuta Thanks for your response. now I'm using the docker image suggested by you and Django application is registering to eureka service now.