org.apache.http.conn.ConnectTimeoutException:连接到本地主机:8761超时

时间:2019-01-21 11:37:30

标签: spring-boot netflix-eureka

将ureka端口号从默认端口更改为自定义端口并运行eureka客户端时,它显示错误。

number_of_enemies = 10
min_enemy_x = 200 
max_enemy_x = 1200
enemy_x_range = max_enemy_x - min_enemy_x   
enemy_zone_width = enemy_x_range / number_of_enemies  
pixel_buffer = 40 

for i in range (number_of_enemies):   
     enemy = Enemy()    # calls the enemy class
     min_x = min_enemy_x + enemy_zone_width * i + pixel_buffer / 2 
     max_x = min_enemy_x + enemy_zone_width * (i + 1) - pixel_buffer / 2  
     enemy.rect.x = random.randrange(min_x, max_x) 

enemy.rect.y = random.randrange(50, 600)                          

enemy_list.add(enemy) # adds the enemy to the group
sprites.add(enemy)

for i in range (10):   # creates 5 enemy spirtes

    coin = Coin()    # calls the coin class
    coin.rect.x = random.randrange(200, 1200, 70) # makes the coin spawn random 
    coin.rect.y = random.randrange(300, 600)

coin_list.add(coin) 
sprites.add(coin)   


def main():  #my main loop 
running = True
clock = pygame.time.Clock()  
score = 0
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

    sprites.update()
    screen.blit(background, (0, 0))
    sprites.draw(screen)
    clock.tick(100)  # Limit the frame rate to 60 FPS.
    pygame.display.flip()   #updates the whole screen



    player_hit_list = pygame.sprite.spritecollide(player, enemy_list, True)
    for enemy in player_hit_list:
        pygame.quit()
    player_hit_list = pygame.sprite.spritecollide(player, coin_list, True)


    for coin in player_hit_list:
        score = (score)+ 1
        print (score)

这是 application.properties 文件内容

if __name__ == '__main__': 
main()

它正在显示

 Caused by: org.apache.http.conn.ConnectTimeoutException: Connect to localhost:8761 timed out
            at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:123) ~[httpclient-4.5.6.jar:4.5.6]
            at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:180) ~[httpclient-4.5.6.jar:4.5.6]
            at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:144) ~[httpclient-4.5.6.jar:4.5.6]
            at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:134) ~[httpclient-4.5.6.jar:4.5.6]
            at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:610) ~[httpclient-4.5.6.jar:4.5.6]
            at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:445) ~[httpclient-4.5.6.jar:4.5.6]
            at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:835) ~[httpclient-4.5.6.jar:4.5.6]
            at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:118) ~[httpclient-4.5.6.jar:4.5.6]
            at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56) ~[httpclient-4.5.6.jar:4.5.6]
            at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:173) ~[jersey-apache-client4-1.19.1.jar:1.19.1]

    eureka.client.registerWithEureka=true
    eureka.client.fetchRegistry=true

1 个答案:

答案 0 :(得分:0)

在eureka注册服务器中添加如下所述的属性:

  client:
  registerWithEureka: false
  fetchRegistry: false
  serviceUrl:
  defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/