我有一个可以工作的kubernetes集群,我想在它上设置一个深流服务。
我创建了以下部署yaml:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: deepstream
namespace: db
spec:
replicas: 1
template:
metadata:
name: deepstream
labels:
app: deepstream
spec:
containers:
- name: deepstream
image: deepstreamio/deepstream.io
ports:
- containerPort: 6020
name: websocket-port
- containerPort: 8080
name: http-port和以下服务yaml:
apiVersion: v1
kind: Service
metadata:
name: deepstream
namespace: db
labels:
service: deepstream
spec:
ports:
- name: websocket
port: 6020
- name: tcp
port: 8080
clusterIP: None
selector:
app: deepstream这看起来像是正确地创建了深流服务。
为了测试它,我创建了一个最小的nodejs脚本:
const deepstream = require('deepstream.io-client-js');
const client = deepstream("<master_ip>:8080/api/v1/proxy/namespaces/db/services/deepstream").login();当我运行脚本时,我得到了以下错误:
/mnt/d/workspace/clients_demo/updates-distributer/deepstream_client/node_modules/deepstream.io-client-js/dist/lib/client.js:204
throw new Error(errorMsg);
^
Error: connectionError: Error: unexpected server response (503) (C)
at Client._$onError (/mnt/d/workspace/clients_demo/updates-distributer/deepstream_client/node_modules/deepstream.io-client-js/dist/lib/client.js:204:11)
at Timeout._onTimeout (/mnt/d/workspace/clients_demo/updates-distributer/deepstream_client/node_modules/deepstream.io-client-js/dist/lib/message/connection.js:319:19)
at ontimeout (timers.js:475:11)
at tryOnTimeout (timers.js:310:5)
at Timer.listOnTimeout (timers.js:270:5)我在deepstream的日志中看到以下几行:
2018-02-07T07:56:37.077476854Z INCOMING_CONNECTION | from undefined (10.1.40.0)
2018-02-07T07:59:37.083807147Z CONNECTION_AUTHENTICATION_TIMEOUT | connection has not authenticated successfully in the expected time
2018-02-07T07:59:37.083949098Z CLIENT_DISCONNECTED | null我做错了什么?
编辑:我最终将服务配置为NodePort类型。
发布于 2019-06-29 19:14:45
我想您应该使用websocket端口6020进行套接字连接,而不是http端点。因为deepstream的http端点不提供连续连接。
const client = deepstream("master_ip>:**8080**/api/v1/proxy/namespaces/db/services/deepstream").login();这应该可以解决问题。
const client = deepstream(**wss://**"master_ip>:**6020**/api/v1/proxy/namespaces/db/services/deepstream").login();https://stackoverflow.com/questions/48658992
复制相似问题