node.js - 无法将nodejs微服务与spring boot应用程序(zuul服务器)连接起来
问题描述
我正在尝试使用 zuul 服务器(api-gateway)将 node.js 微服务与 spring boot 应用程序连接起来。
zuul application.properties:
spring.application.name=api-gateway
hystrix.shareSecurityContext=true
eureka.client.service-url.default-zone=http://localhost:8761/eureka
zuul.routes.node-simple.serviceId=node-simple
zuul.routes.node-simple.path=/node-simple/**
zuul.routes.home.path=/home
zuul.routes.home.url=http://localhost:8080
zuul.sensitive-headers=Cookie,Set-Cookie
server.port=8080
节点js尤里卡配置
const client = new Eureka({
instance: {
id: appName,
instanceId: 'node',
app: appName,
hostName: 'localhost',
ipAddr: '127.0.0.1',
statusPageUrl: 'http://localhost:8200',
port: {
'$': PORT,
'@enabled': 'true',
},
vipAddress: appName,
dataCenterInfo: {
'@class': 'com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo',
name: 'MyOwn',
}
},
eureka: {
host: 'localhost',
port: 8761,
servicePath: '/eureka/apps/'
}
});
当我尝试在 eureka 上访问 zuul (api-gateway) 的 URL 时,出现此错误:
负载均衡器没有可用于客户端的服务器:node-simple
解决方案
这是我在 zuul 设置中的配置。zuul 设置从 Eureka 服务器获取路由信息
zuul.sensitive-headers= Cookie,Set-Cookie
zuul.strip-prefix=false
zuul.debug.request=true
spring.application.name= zuul-server
eureka.instance.preferIpAddress=true
eureka.client.registerWithEureka=true
eureka.client.fetchRegistry=true
eureka.client.serviceUrl.defaultZone=${EUREKA_URI:http://localhost:8761/eureka}
下面是我的尤里卡配置
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
eureka.server.enable-self-preservation=false
为了能够注册 nodejs 应用程序并在路由请求时找到它,我按照这里的教程进行操作。实现与 Eureka 服务器的连接并保持通信
推荐阅读
- javascript - 从多个元素的值创建 JSON 对象的动态数组
- c# - Xamarin Android C# SQLite 参数查询
- python - Python 3.x 更改最后打印的行 end="\r" 不起作用
- c++ - C++ 代码在一台机器上运行,但在另一台机器上出现 seg 错误
- javascript - 如何在本机反应中根据数量更改产品的价值
- python - python添加询问用户
- angularjs - 如何在隔离范围内检索自定义属性?
- python - Python - 遍历列表字典
- javascript - 当我使用 ajax 并在之后填充和创建表时,jQuery 使用 [id^=''] 获取 id
- java - 从本地 GlassFish 连接到 Heroku PostgreSQL 的问题