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
187 stars 44 forks source link

"IndexError: list index out of range" for eureka server with domain name #2

Closed rasisuku closed 5 years ago

rasisuku commented 5 years ago

getting index out of range, when we use eureka server url with domain name. however it works with ip.

Error trace:

Eureka Server Url: http://myeureka.test.com:8077 Traceback (most recent call last): File "src\test_eureka.py", line 324, in eureka_client.init_registry_client(eureka_server=Eureka_Server, app_name="eureka-test", instance_port=app_port) File "C:\Users\dummyuser\AppData\Roaming\Python\Python37\site-packages\py_eureka_client\eureka_client.py", line 788, in init_registry_client is_coordinating_discovery_server=is_coordinating_discovery_server) File "C:\Users\dummyuser\AppData\Roaming\Python\Python37\site-packages\py_eureka_client\eureka_client.py", line 569, in init self.try_all_eureka_server(try_to_get_client_ip) File "C:\Users\dummyuser\AppData\Roaming\Python\Python37\site-packages\py_eureka_client\eureka_client.py", line 619, in try_all_eureka_server fun(url) File "C:\Users\dummyuser\AppData\Roaming\Python\Python37\site-packages\py_eureka_client\eureka_client.py", line 558, in try_to_get_client_ip self.instance_host = self.__instance_ip = RegistryClient.get_instance_ip(url) File "C:\Users\dummyuser\AppData\Roaming\Python\Python37\site-packages\py_eureka_client\eureka_client.py", line 656, in __get_instance_ip target = re_result[0] IndexError: list index out of range

keijack commented 5 years ago

I will check it out, the problem occurs when trying to get the client IP, you could bypass this error by specifying the instance_host or instance_ip` in the init_registry_client:

your_rest_server_host = "http://your_eureka_component_host"
your_rest_server_port = 9090

eureka_client.init_registry_client(eureka_server="http://your-eureka-server-peer1,http://your-eureka-server-peer2",
                                app_name="your_app_name",
                                instance_host=your_rest_server_host ,
                                instance_port=your_rest_server_port)

Thank you.

keijack commented 5 years ago

bug fixed, please update to the newest version [0.1.1]. @rasisuku