Search code examples
deepstream.io

deepstream error listen EADDRINUSE 127.0.0.1:6020


i try to run my first deepstream.io server from this link but i get this error :

enter image description here

error:

CONNECTION_ERROR | Error: listen EADDRINUSE 127.0.0.1:3003
PLUGIN_ERROR | connectionEndpoint wasn't initialised in time
f:\try\deep\node_modules\deepstream.io\src\utils\dependency-
initialiser.js:96
throw error
^

Error: connectionEndpoint wasn't initialised in time
at DependencyInitialiser._onTimeout 
(f:\try\deep\node_modules\deepstream.io\src\utils\dependency-
initialiser.js:94:17)
at ontimeout (timers.js:386:14)
at tryOnTimeout (timers.js:250:5)
at Timer.listOnTimeout (timers.js:214:5)

and this is my code:

const DeepStreamServer = require("deepstream.io")
const C = DeepStreamServer.constants;
const server = new DeepStreamServer({
  host:'localhost',
  port:3003
})

server.start();

Solution

  • In deepstream 3.0 we released our HTTP endpoint, by default this runs alongside our websocket endpoint.

    Because of this, passing the port option at the root level of the config no longer works (it overrides both the HTTP and websocket port options, as you can see in the screen capture provided, both endpoints are trying to start on the same port).

    You can override each of these ports as follows:

    const deepstream = require('deepstream.io')
    
    const server = new deepstream({
      connectionEndpoints: {
        http: {
          options: {
            port: ...
          }
        },
        websocket: {
          options: {
            port: ...
          }
        }
      }
    })
    server.start()
    

    Or you can define your config in a file and point to that while initialising deepstream[1].

    [1] deepstream server configuration