Skip to content

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

Description

@RajatDudejaj

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions