Nodejs on GCE Error: Client network socket disconnected before secure TLS connection was established

Nodejs on GCE Error: Client network socket disconnected before secure TLS connection was established

我正在使用 nodejs 版本 12,部署在 google 云引擎容器

有时,当我向也在 google 云引擎上部署的其他微服务发送 http 请求时,我会收到此消息

错误:客户端网络套接字在建立安全 TLS 连接之前断开连接

更新

这是一个正常的 docker 容器,发布在 google 云引擎上,配置正常

这是我的docker文件配置

# ---- Base Node ----
FROM node:12-alpine AS base 
ARG env=dev
ENV NODE_ENV=${env}
# install node
RUN apk add --no-cache tini  
# set working directory
WORKDIR /app
# Set tini as entrypoint
ENTRYPOINT ["/sbin/tini", "--"]
# copy project file
COPY package.json .

# ---- Dependencies ----
FROM base AS dependencies
# install node packages
RUN npm set progress=false && npm config set depth 0
RUN npm install --only=production 
# copy production node_modules aside
RUN cp -R node_modules prod_node_modules
# install ALL node_modules, including 'devDependencies'
RUN npm install

#
# ---- Test ----
# run linters, setup and tests
FROM dependencies AS build
COPY . .
RUN  npm run lint
RUN  npm run build

#
# ---- Release ----
FROM base AS release
# copy production node_modules
COPY --from=dependencies /app/prod_node_modules ./node_modules
COPY --from=build /app/build ./build
# copy app sources
COPY . .
# expose port and define CMD
EXPOSE 8080

CMD npm run start

您的负载均衡器似乎需要 HTTPS 连接而不是 HTTP(此时您的容器正在提供)。

就像@john-hanley 提到的那样,但在这种情况下,您可以将容器后端配置为提供 HTTPS 连接,或者 configure 您的负载均衡器使用纯 HTTP 与后端“对话”。

您仍然可以为您的最终用户提供 HTTPS 连接,但到目前为止,这个问题似乎出在您的负载平衡器和后端之间。