1

I have a working kubernetes cluster, and I'd like to setup a deepstream service on it.

I created the following deployment 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

And the following service 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

It looks like this creates the deepstream service correctly.

To test it, I created a minimal nodejs script:

const deepstream = require('deepstream.io-client-js');
const client = deepstream("<master_ip>:8080/api/v1/proxy/namespaces/db/services/deepstream").login();

When I run the script, I ger the following error:

/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)

And I see the following lines in deepstream's log:

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

What am I doing wrong?

EDIT: I ended up configuring the service to be of type NodePort.

akir94
  • 55
  • 1
  • 8

1 Answers1

0

I guess you should use websocket port 6020 for socket connections not the http endpoint. Because http endpoint of deepstream does not provide continuous connection.

const client = deepstream("master_ip>:**8080**/api/v1/proxy/namespaces/db/services/deepstream").login();

this should solve the problem.

const client = deepstream(**wss://**"master_ip>:**6020**/api/v1/proxy/namespaces/db/services/deepstream").login();
Abhishek Gurjar
  • 7,426
  • 10
  • 37
  • 45