我在Heroku部署了3个服务。
网关和微服务在Eureka注册。
网关application.yml
server:
port: ${PORT:8080}
eureka:
instance:
hostname: gateway.herokuapp.com
homePageUrl: https://${eureka.instance.hostName}/
client:
serviceUrl:
defaultZone: http://eureka.herokuapp.com/eureka/
spring:
application:
name: gateway-service
cloud:
gateway:
routes:
- id: employeeModule
uri: lb://MICROSERVICE
predicates:
- Path=/employee/**
logging:
level:
org.springframework.cloud.gateway: TRACE
尤里卡应用程序.yml
server:
port: ${PORT:8761}
eureka:
instance:
hostname: ${EUREKA_HOSTNAME:localhost}
client:
register-with-eureka: false
fetch-registry: false
service-url:
defaultZone: ${EUREKA_URI:http://${eureka.instance.hostname}:${server.port}/eureka/}
spring:
application:
name: MICROSERVICE
server:
port: ${PORT:8081}
eureka:
instance:
hostname: microservice.herokuapp.com
homePageUrl: https://${eureka.instance.hostName}/
home-page-url-path: https://${eureka.instance.hostName}
client:
serviceUrl:
defaultZone: http://eureka.herokuapp.com/eureka/
但它不是路由到https://microserviceurl/employee/message
,而是路由到带有随机heroku端口的eureka版本。例如:https://microserviceurl:randomherokuport/employee/message
。由于超时,这导致错误503。
有没有办法告诉网关忽略端口号?还是我做错了什么?
网关日志
2020-08-18T19:59:56.683925+00:00 app[web.1]: 2020-08-18 19:59:56.683 TRACE 4 --- [or-http-epoll-1] o.s.c.g.filter.LoadBalancerClientFilter : LoadBalancerClientFilter url chosen: http://microservice.herokuapp.com:41632/employee/message
2020-08-18T20:00:26.673252+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/employee/message" host=gateway.herokuapp.com request_id=236faa79-1d66-4e30-8c32-f879228d08db fwd="79.205.56.29" dyno=web.1 connect=1ms service=30001ms status=503 bytes=0 protocol=https
解决方案是在application.yml中为eureka实例设置安全端口和非安全端口
微服务应用程序.yml
spring:
application:
name: MICROSERVICE
server:
port: ${PORT:8081}
eureka:
instance:
hostname: microservice.herokuapp.com
homePageUrl: https://${eureka.instance.hostName}/
home-page-url-path: https://${eureka.instance.hostName}
client:
serviceUrl:
defaultZone: http://eureka.herokuapp.com/eureka/
non-secure-port: 80
secure-port: 443
我在后端使用微服务架构,其中我使用TypeScript创建服务,其他使用Java创建服务。我还有一个Spring网关和一个Eureka服务器(都使用Spring)。 然后,Gateway工作正常,Eureka工作正常,用Java编写的其他微服务也工作正常。问题是当我试图通过网关访问TypeScript微服务时。 我有一个简单的Eureka服务器,在Spring使用注释EnableEurekaSer
我对docker,Spring框架的一切都很陌生…它们成功地在localhost环境中运行,现在我想把它们推送到docker中,但是总是给我错误,我在那里卡住了大约一周。有人能帮我弄清楚吗!!! 现在我有 eureka 服务器和云配置服务器服务,这是我的代码: 尤里卡服务器应用程序.yml 和 Dockerfile: 现在我有云配置服务器应用程序.yml:在这个文件中,我试图在github上备份它
pom.xml 主应用程序类 Application.Properties eureka客户端设置 pom.xml Application.Properties 我在eureka-server仪表板(http://localhost:8761)中没有看到向Eureka server注册的micro-service-currency-exchange-service 为什么eureka客户端没有注册
在我的spring boot应用程序中,我使用eureka进行服务发现,使用ribbon进行负载平衡。当我在固定端口上运行我的注册到eureka的微服务时,它工作正常,但当我在随机端口上运行它们时,虽然我可以看到在eureka仪表板上注册的服务,但它无法找到端口号。当我尝试点击服务时,我得到了下面的错误。 这是我的控制器类,我从其中调用另一个服务。 这是我添加的属性 我的服务是在名为MYAPP的e
在单体架构时,因为服务不会经常和动态迁移,所有服务地址可以直接在配置文件中配置,所以也不会有服务发现的问题。但是对于微服务来说,应用的拆分,服务之间的解耦,和服务动态扩展带来的服务迁移,服务发现就成了微服务中的一个关键问题。 服务发现分为客户端服务发现和服务端服务发现两种,架构如下图所示。 这两种架构都各有利弊,我们拿客户端服务发现软件Eureka和服务端服务发现架构Kubernetes/SkyD