Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python eureka service is getting registered deregistered in prod multiple times #71

Open
RajatDudejaj opened this issue Sep 15, 2022 · 0 comments

Comments

@RajatDudejaj
Copy link

RajatDudejaj commented Sep 15, 2022

Hi Keijack,

Nice tutorial. I am having Python and spring boot services on eureka but Python service is frequently coming in Last 1000 newly registered leases and no other service is coming. It is not getting heartbeat, may I know the reason or solution for the same? My register method

def register_eureka(should_register=True):
server_host = 'xyz.com'
eureka_url = 'https://xyz.com/'
homePageUrl = 'https://' + server_host
healthCheckUrl = 'https://' + server_host + '/healthCheck'
eureka_client.init(eureka_server=eureka_url,
app_name='AppName',
zone='zone1',
instance_host=server_host,
instance_secure_port_enabled=True,
instance_unsecure_port_enabled=False,
instance_secure_port=443,
home_page_url=homePageUrl,
status_page_url=healthCheckUrl,
health_check_url=healthCheckUrl,
ha_strategy=eureka_client.HA_STRATEGY_RANDOM,
instance_port=8080,
should_register=should_register)

My method to get service from eureka:

def getUpInstancesFromEureka(serviceName):

# register_eureka(should_register=False) # this wont not register eureka everytime we call this method
client = eureka_client.get_client()
app = client.applications.get_application(serviceName)
up_instances = app.up_instances
#up_instances_same_zone = app.up_instances_in_zone(client.zone)
#up_instances_other_zone = app.up_instances_not_in_zone(client.zone)
print("Following instances are UP:")
for instance in up_instances:
    print(instance.hostName)

if len(up_instances) < 1:
    raise Exception("No eureka instances UP for service --> " + serviceName)

instanceIndex = random.randint(0,len(up_instances) - 1)
print("Selecting instance --> " + up_instances[instanceIndex].hostName)

url = 'https://' + up_instances[instanceIndex].hostName
return url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant