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

Can not Pull registry from eureka server. #69

Open sdhzlzhk opened 2 years ago

sdhzlzhk commented 2 years ago

I depolyed a django server with uwsgi. the django server will call other-service, when I restart the other-service , the django eureka client call other-server raise URLError. the error log is below: Exception ignored in thread started by: <function genHeat at 0x7f39d2391700> Traceback (most recent call last): File "/usr/src/app/./PythonToolService/terrainPointRequest.py", line 177, in genHeat eureka_client.do_service("WINDEYFOAM-WEB", "/wdeyCalculateProjectItemMapResult/updateByIdForPython/"+id+"/"+str(type)+"/2") File "/usr/local/lib/python3.9/site-packages/py_eureka_client/eureka_client.py", line 1310, in do_service return get_event_loop().run_until_complete(do_service_async(app_name=app_name, service=service, return_type=return_type, File "/usr/local/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete return future.result() File "/usr/local/lib/python3.9/site-packages/py_eureka_client/eureka_client.py", line 1180, in do_service_async res = await cli.do_service(app_name=app_name, service=service, return_type=return_type, File "/usr/local/lib/python3.9/site-packages/py_eureka_client/eureka_client.py", line 937, in do_service return await self.walk_nodes(app_name, service, prefer_ip, prefer_https, walk_using_urllib) File "/usr/local/lib/python3.9/site-packages/py_eureka_client/eureka_client.py", line 894, in walk_nodes return await obj File "/usr/local/lib/python3.9/site-packages/py_eureka_client/eureka_client.py", line 929, in walk_using_urllib res: http_client.HttpResponse = await http_client.http_client.urlopen( File "/usr/local/lib/python3.9/site-packages/py_eureka_client/http_client.py", line 148, in urlopen res = urllib.request.urlopen(req._to_urllib_request(), data=data, timeout=timeout) File "/usr/local/lib/python3.9/urllib/request.py", line 214, in urlopen return opener.open(url, data, timeout) File "/usr/local/lib/python3.9/site-packages/skywalking/plugins/sw_urllib_request.py", line 48, in _sw_open res = _open(this, fullurl, data, timeout) File "/usr/local/lib/python3.9/urllib/request.py", line 517, in open response = self._open(req, data) File "/usr/local/lib/python3.9/urllib/request.py", line 534, in _open result = self._call_chain(self.handle_open, protocol, protocol + File "/usr/local/lib/python3.9/urllib/request.py", line 494, in _call_chain result = func(*args) File "/usr/local/lib/python3.9/urllib/request.py", line 1375, in http_open return self.do_open(http.client.HTTPConnection, req) File "/usr/local/lib/python3.9/urllib/request.py", line 1349, in do_open raise URLError(err) urllib.error.URLError:

keijack commented 2 years ago

Are there any other logs when pulling the registry? When is your service "WINDEYFOAM-WEB" up? Is it later than the python service? The library will pull the registry every 30 seconds if you are not set the interval time configuration.

sdhzlzhk commented 2 years ago

eureka_client.init(eureka_server=EUREKA_DEFAULT_ZONE, app_name="WINDEYFOAM-DJANGO", instance_host=INSTANCE_IP, instance_port=SERVER_PORT, ha_strategy=eureka_client.HA_STRATEGY_RANDOM, on_error=on_err, renewal_interval_in_secs=4, duration_in_secs=12, is_coordinating_discovery_server=True ) I set interval 4 seconds. The "WINDEYFOAM-WEB" and "WINDEYFOAM-DJANGO" is up, call back is ok. When I restart "WINDEYFOAM-WEB", "WINDEYFOAM-DJANGO" called "WINDEYFOAM-WEB" failed. the uwsgi config below: [uwsgi] chdir=/usr/src/app module=PythonToolService.wsgi:application master=True socket=/usr/src/app/uwsgi.sock pidfile=/usr/src/app/uwsgi.pid http=0.0.0.0:8093 vacuum=True processes = 4 threads=10 max-requests=5000 enable-threads=true harakiri=120 harakiri-verbose=true

daemonize=/var/log/app.log

log-master=true buffer-size=65536 post-buffering=8192

add-header=Connection: close

log-date=%%Y-%%m-%%d %%H:%%M:%%S logformat-strftime=true logformat=%(ftime) | uWSGI | %(addr) (%(proto) %(status)) | %(method) %(uri) | %(pid):%(wid) | Returned %(size) bytes in %(msecs) ms to %(uagent)

py_eureka_client log: [2022-08-16 14:17:53]-[HeartbeatThread]-[eureka_client:839] DEBUG: instance [10.244.164.158:Windeyfoam-Web:9002] has DELETED [2022-08-16 14:18:09]-[HeartbeatThread]-[eureka_client:839] DEBUG: instance [10.244.164.158:Windeyfoam-Web:9002] has DELETED [2022-08-16 14:18:09]-[HeartbeatThread]-[eureka_client:839] DEBUG: instance [10.244.192.73:Windeyfoam-Web:9002] has ADDED [2022-08-16 14:18:09]-[HeartbeatThread]-[eureka_basic:196] DEBUG: update instance 10.244.192.73:Windeyfoam-Web:9002 [2022-08-16 14:21:10]-[HeartbeatThread]-[eureka_client:839] DEBUG: instance [10.244.192.73:Windeyfoam-Web:9002] has ADDED [2022-08-16 14:21:10]-[HeartbeatThread]-[eureka_basic:196] DEBUG: update instance 10.244.192.73:Windeyfoam-Web:9002