1

我有一个工作的 kubernetes 集群,我想在它上面设置一个 deepstream 服务。

我创建了以下部署 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

看起来这正确地创建了 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 类型。

4

1 回答 1

0

我想您应该将 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();
于 2019-06-29T11:14:45.280 回答