我试图运行两个应用程序的港口-撰写,但没有成功,联邦无法连接服务。两人都在码头外工作得很好。
以下是项目的后续行动:
)
Kotlin + Spring + expediagroup:graphql-kotlin-spring-server中的
docker-compose.yml
version: '3'
services:
myservice:
image: 'myservice:0.0.1-SNAPSHOT'
container_name: myservice_container
ports:
- 8080:8080
expose:
- 8080
apollo_federation:
image: 'apollo-federation'
build: '.'
container_name: apollo_federation_container
restart: always
ports:
- 4000:4000
expose:
- 4000
environment:
ENDPOINT: "http://myservice/graphql"
depends_on:
- myservice我已经在端点ex中尝试了许多组合:http://myservice:8080/graphql、http://localhost:8080/graphql、http://myservice等等.
index.js来自阿波罗计划
const { ApolloServer } = require("apollo-server");
const { ApolloGateway } = require("@apollo/gateway");
const gateway = new ApolloGateway({
serviceList: [
{ name: "Service1", url: process.env.ENDPOINT || 'http://localhost:8080/graphql' },
]
});
const server = new ApolloServer({
gateway,
subscriptions: false
});
server.listen().then(({ url }) => {
console.log(` Server ready at ${url}`);
})错误日志
Error checking for changes to service definitions: Couldn't load service definitions for "Service1" at http://myservice/graphql: request to http://myservice/graphql failed, reason: connect ECONNREFUSED 172.18.0.3:80如果我尝试从浏览中进行测试,我就会得到一个错误500。
我已经尝试使用nginx作为反向代理,但没有成功。
我在项目中使用的是最后一个子类。
谢谢
发布于 2020-07-06 23:40:03
在代码中,您正在使用
{ name: "Service1", url: process.env.ENDPOINT || 'http://localhost:8080/graphql' },它正在拖动process.env.ENDPOINT,它在您的停靠-撰写文件中定义为使用端口80:
environment:
ENDPOINT: "http://myservice/graphql" # This is port 80https://stackoverflow.com/questions/62563924
复制相似问题