Closed PriyatamNayak closed 3 years ago
2020-10-09T19:00:40.371+08:00 [APP/PROC/WEB/0] [OUT] self.try_all_eureka_servers(fun) 2020-10-09T19:00:40.371+08:00 [APP/PROC/WEB/0] [OUT] File "/home/vcap/deps/0/python/lib/python3.8/site-packages/py_eureka_client/eureka_client.py", line 1000, in try_all_eureka_servers 2020-10-09T19:00:40.371+08:00 [APP/PROC/WEB/0] [OUT] self.try_eureka_server_not_in_zone(fun) 2020-10-09T19:00:40.371+08:00 [APP/PROC/WEB/0] [OUT] File "/home/vcap/deps/0/python/lib/python3.8/site-packages/py_eureka_client/eureka_client.py", line 983, in try_eureka_server_not_in_zone 2020-10-09T19:00:40.371+08:00 [APP/PROC/WEB/0] [OUT] raise http_client.URLError("All eureka servers in all zone are down!")
eureka_client.init(app_name="app", eureka_server= "https://eureka-85b8fd12-44b3-4f8d-9d40-860b8be81cd9..xxx.com", eureka_context="/eureka/",should_register=True,should_discover=False)
Anyone can help me??
@keijack Coudl you please help me
You are using a HTTPS
connection, is that a self-certificated connection or a valid one? If you visit the https://eureka-85b8fd12-44b3-4f8d-9d40-860b8be81cd9..xxx.com
in your browser, is there a warning?
There is no warning ..
On Sat, 10 Oct 2020 at 9:02 AM, Keijack notifications@github.com wrote:
You are using a HTTPS connection, is that a self-certificated connection or a valid one? If you visit the https://eureka-85b8fd12-44b3-4f8d-9d40-860b8be81cd9..xxx.com in your browser, is there a warning?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/keijack/python-eureka-client/issues/35#issuecomment-706459501, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJXNYTD76ENHSCJNHNKGKETSJ6XAVANCNFSM4SJ562OQ .
--
Regards Priyatam Nayak+6584584608
I add more logs at registering exception, please upgrade to version 0.8.4 and provide more logs, please.
2020-10-10 03:43:41]-[eureka_client]-[line:1085] -ERROR: Eureka server [ 03:43:41]-[eureka_client]-[line:1085] -ERROR: Eureka server [https://eureka-85b8fd12-44b3-4f8d-9d40-860b8be81cd9.xxxxx.com/eureka/] is down, use next url to try.
2020-10-10T11:43:41.809+08:00 [APP/PROC/WEB/0] [OUT] Traceback (most recent call last):
2020-10-10T11:43:41.809+08:00 [APP/PROC/WEB/0] [OUT] File "/home/vcap/deps/0/python/lib/python3.8/site-packages/py_eureka_client/eureka_client.py", line 1099, in connect_to_eureka_server
2020-10-10T11:43:41.809+08:00 [APP/PROC/WEB/0] [OUT] self.__try_eureka_server_in_cache(fun)
2020-10-10T11:43:41.809+08:00 [APP/PROC/WEB/0] [OUT] File "/home/vcap/deps/0/python/lib/python3.8/site-packages/py_eureka_client/eureka_client.py", line 1041, in try_eureka_server_in_cache
2020-10-10T11:43:41.809+08:00 [APP/PROC/WEB/0] [OUT] fun(url)
2020-10-10T11:43:41.809+08:00 [APP/PROC/WEB/0] [OUT] File "/home/vcap/deps/0/python/lib/python3.8/site-packages/py_eureka_client/eureka_client.py", line 1151, in
Have tried with “/eureka and eureka Same error
On Sat, 10 Oct 2020 at 10:54 AM, Keijack notifications@github.com wrote:
What if remove the last / at eureka_context="/eureka/"? Make it to eureka_context="/eureka"?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/keijack/python-eureka-client/issues/35#issuecomment-706474225, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJXNYTHHCKEJ27UI72SSWD3SJ7EFPANCNFSM4SJ562OQ .
--
Regards Priyatam Nayak+6584584608
I think it is using oauth to get access..is there any way I can pass oauth authentication instead of user and password ..
On Sat, 10 Oct 2020 at 12:14 PM, Priyatam Nayak prisankunyk@gmail.com wrote:
Have tried with “/eureka and eureka Same error
On Sat, 10 Oct 2020 at 10:54 AM, Keijack notifications@github.com wrote:
What if remove the last / at eureka_context="/eureka/"? Make it to eureka_context="/eureka"?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/keijack/python-eureka-client/issues/35#issuecomment-706474225, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJXNYTHHCKEJ27UI72SSWD3SJ7EFPANCNFSM4SJ562OQ .
--
Regards Priyatam Nayak+6584584608
--
Regards Priyatam Nayak+6584584608
In that case, I think you need to define the HTTP Client to make it work. https://github.com/keijack/python-eureka-client#use-other-http-client
Please see below.. curl https://eureka-85b8fd12-44b3-4f8d-9d40-860b8be.xx.xxxx.com/eureka
it is using ouath authentication...am able to curl using oauth token
Token=curl -k "https://p-spring-cloud-services.xxx.com/oauth/token" -u "p-service-registry-e11a1cb3-36e8-4e5c-8762-bedcbdab7751":"qeg337JQRRAf" -d grant_type=client_credentials
curl -k -H "Authorization: bearer $Token" -H "Accept: application/json" https://eureka-85b8fd12-44b3-4f8d-9d40-860b8be8.xxxxx.com/eureka
Note: It is using oauth authentication , Could you please give option to use oauth authentication by providing ouath uri ,client id and password instead of basic one (userid and apssword)
Could you please share sample code to use oauth? Please
Is there a expiration of the token? Do you need to refresh the token every maybe one hour or something?
yes...expiration is there ..ie 29 seconds
But spring boot app ..they are passing only the eureka server URL..
On Sat, 10 Oct 2020 at 2:18 PM, Keijack notifications@github.com wrote:
Is there a expiration of the token? Do you need to refresh the token every maybe one hour or something?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/keijack/python-eureka-client/issues/35#issuecomment-706496108, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJXNYTGEYJHXFBHUBX4BS6DSJ74CNANCNFSM4SJ562OQ .
--
Regards Priyatam Nayak+6584584608
In Springboot app, do you have any OAuth configurations in your yml/properties file?
No
On Sat, 10 Oct 2020 at 3:21 PM, Keijack notifications@github.com wrote:
In Springboot app, do you have any OAuth configurations in your yml/properties file?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/keijack/python-eureka-client/issues/35#issuecomment-706503250, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJXNYTBQ4KAHPEL4EXI5PZ3SKADRPANCNFSM4SJ562OQ .
--
Regards Priyatam Nayak+6584584608
There is using exactly same as described above..
On Sat, 10 Oct 2020 at 3:52 PM, Priyatam Nayak prisankunyk@gmail.com wrote:
No
On Sat, 10 Oct 2020 at 3:21 PM, Keijack notifications@github.com wrote:
In Springboot app, do you have any OAuth configurations in your yml/properties file?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/keijack/python-eureka-client/issues/35#issuecomment-706503250, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJXNYTBQ4KAHPEL4EXI5PZ3SKADRPANCNFSM4SJ562OQ .
--
Regards Priyatam Nayak+6584584608
--
Regards Priyatam Nayak+6584584608
The example you posted does not have any OAuth configurations, I don't think it need a OAuth token header added when register to the Eureka server, but in YORU situation, you first use curl
to acquire a token and then set it when visit the eureka server. There must be some configuration in somewhere to set up this authentication.
However, the following code should meet your need.
import urllib.request
import ssl
import time
import socket
import base64
from threading import Thread
import py_eureka_client.http_client as http_client
import py_eureka_client.eureka_client as eureka
_UNSECURE_SSL_CTX = ssl.create_default_context()
_UNSECURE_SSL_CTX.check_hostname = False
_UNSECURE_SSL_CTX.verify_mode = ssl.CERT_NONE
_OAUTH_TOKEN_RENEW_TIME = 30
_OAUTH_BASIC_AUTH = base64.standard_b64encode("p-service-registry-e11a1cb3-36e8-4e5c-8762-bedcbdab7751:qeg337JQRRAf".encode()).decode()
_OAUTH_URL = "https://p-spring-cloud-services.xxx.com/oauth/token"
_EUREKA_URL = "eureka-85b8fd12-44b3-4f8d-9d40-860b8be81cd9.xxx.com"
class Token:
def __init__(self):
self._token = ""
self._refresh_thread = Thread(target=self._load_token_interval, name="oauth-refresh-thread", daemon=True)
@property
def token(self):
if not self._token:
self.start()
return self._token
def start(self):
self._load_token()
self._refresh_thread.start()
def _load_token_interval(self):
while(True):
time.sleep(_OAUTH_TOKEN_RENEW_TIME)
self._load_token()
def _load_token(self):
tkreq = urllib.request.Request(_OAUTH_URL, method="POST", headers={'Authorization': 'Basic %s' % _OAUTH_BASIC_AUTH})
tkres = urllib.request.urlopen(tkreq, context=_UNSECURE_SSL_CTX, data="grant_type=client_credentials".encode())
self._token = tkres.read().decode().strip()
class MyHttpClient(http_client.HttpClient):
def __init__(self, *args, **kw):
super().__init__(*args, **kw)
self._token = Token()
def urlopen(self):
eureka_urls = [eurl.strip() for eurl in _EUREKA_URL.split(',')]
if self.request.host in eureka_urls:
self.context = _UNSECURE_SSL_CTX
self.request.add_header("Authorization", "bearer %s" % self._token.token)
return super().urlopen()
http_client.set_http_client_class(MyHttpClient)
eureka.init(
eureka_server=_EUREKA_URL,
eureka_protocol="https",
eureka_context="/eureka",
should_discover=False,
app_name="app",
instance_port=9191)
able to register ....Thank you so much.. yes..just change Little bit...to pass the authentication
Can you remove the eureka link..can you mask it with xxxx
Of course. Edited.
Thank you so much @keijack .. I think you can add this as a functionality in next release ..Thanks again..closing this
Eureka Client无法connect到Eureka server? [W 191023 10:46:08 eureka_client:644] Eureka server [https://eureka-85b8fd12-44b3-4f8d-9d40-860b8be81cd9..xxx.com/eureka/] is down, use next url to try. [2019-10-23 10:46:08]-[EurekaClient]-[line:704] -ERROR: error! Traceback (most recent call last): File "/application/anaconda3/lib/python3.7/site-packages/py_eureka_client/eureka_client.py", line 718, in send_heart_beat self.try_all_eureka_server(lambda url: send_heart_beat(url, self.__instance["app"], File "/application/anaconda3/lib/python3.7/site-packages/py_eureka_client/eureka_client.py", line 654, in try_all_eureka_server raise http_client.URLError("All eureka servers are down!") urllib.error.URLError: <urlopen error All eureka servers are down!> During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/application/anaconda3/lib/python3.7/site-packages/py_eureka_client/eureka_client.py", line 702, in register self.try_all_eureka_server(lambda url: _register(url, self.instance)) File "/application/anaconda3/lib/python3.7/site-packages/py_eureka_client/eureka_client.py", line 654, in __try_all_eureka_server raise http_client.URLError("All eureka servers are down!") urllib.error.URLError: <urlopen error All eureka servers are down!>