Delaying sockets start

Technical Support
  • How can I delay the sockets start?
    I found this code block on start.js:

    function (next) {
      var webserver = require('./webserver');
      require('./socket.io').init(webserver.server);
    
      if (nconf.get('runJobs')) {
        require('./notifications').startJobs();
        require('./user').startJobs();
      }
      webserver.listen(next);
    }
    

    All I want to obtain is to run the server first and 1-3 seconds later to start the sockets.
    What I don't want is to rewrite in the src folder.

    Alternatively I could overwrite in a plugin the Sockets.init function.
    What do you suggest?

  • Why do you want to? Perhaps there is an alternative solution.

  • @PitaJ NodeBB is installed on a server and I'm using a proxy to serve it.
    Both servers are on Heroku on free Dynos. If nodeBB is sleeping, the proxy server will wake it up, but when it starts it throws a socket error and the proxy server displays the "Application error" page.
    But in reality NodeBB server started okay.

  • @PitaJ the thing I never managed to start NodeBB on Heroku with web: node loader.js --no-daemon, but only with web: node app.js and maybe I wouldn't have this issue now.

  • Delaying the sockets start didn't solved the problem. So I'm still looking for the solution.

    But I managed to start the server as it should.

    PS: would've been great to have the option to close the topic.

  • It looks like is a configuration problem. When I load the page, there is this network error:

    socket.io.js:8 WebSocket connection to 'wss://example.com/socket.io/?EIO=3&transport=websocket&sid=zV8kYkx-87ULGIjGAAAF' failed: Error in connection establishment: net::ERR_SSL_PROTOCOL_ERROR

    On Chrome's inspector window it says it was canceled.
    But then it works normal.
    So all I need is to bypass the first error... or even better, fix it.


Suggested Topics


  • 0 Votes
    10 Posts
    261 Views

    Great! Thanks for checking in with your solution 😃

  • 0 Votes
    4 Posts
    2k Views

    @mroczny
    No, in the previous update, a redis package was replaced via ioredis package. And that change is broke your configuration.
    Related PR: https://github.com/NodeBB/NodeBB/pull/9545

  • 0 Votes
    1 Posts
    159 Views

    Hello,
    I was installing NodeBB today and I after a successful install, I tried running nodebb start only for the nodejs script to pop up and the code to crash. This was in my nodebb log :
    NodeBB Error.PNG
    I couldn't find anything questions similar my issue and any help would be appreciated.

  • 0 Votes
    1 Posts
    442 Views

    Hello,

    after a server reset NodeBB doesn't start regularly anymore.

    using

    ./nodebb -l --log-level verbose start

    I get

    2018-08-03T07:00:55.445Z [32024] - verbose: * using configuration stored in: /var/www/html/nodebb.freeplaying.it/nodebb/config.json

    Starting NodeBB with logging output
    Hit Ctrl-C to exit
    The NodeBB process will continue to run in the background
    Use "./nodebb stop" to stop the NodeBB server
    2018-07-29T20:35:45.659Z [1479] - info: Routes added
    2018-07-29T20:35:45.663Z [1479] - info: NodeBB Ready
    2018-07-29T20:35:45.666Z [1479] - info: Enabling 'trust proxy'
    2018-07-29T20:35:45.673Z [1479] - info: NodeBB is now listening on: 0.0.0.0:4567
    2018-07-29T20:58:31.312Z [1479] - info: [app] Shutdown (SIGTERM/SIGINT) Initialised.
    2018-07-29T20:58:31.313Z [1479] - info: [app] Web server closed to connections.
    2018-07-29T20:59:38.440Z [1479] - info: [app] Database connection closed.
    2018-07-29T20:59:38.441Z [1479] - info: [app] Shutdown complete.
    [cluster] Child Process (1479) has exited (code: 0, signal: null)

    Log doesn't have any traces of malfunctioning plugins or the likes. Running a

    ./nodebb -d start

    I get this:

    2018-08-03T07:02:56.411Z [32535] - verbose: * using configuration stored in: /var/www/html/nodebb.freeplaying.it/nodebb/config.json

    NodeBB v1.10.1 Copyright (C) 2013-2014 NodeBB Inc.

    This program comes with ABSOLUTELY NO WARRANTY.

    This is free software, and you are welcome to redistribute it under certain conditions.

    For the full license, please visit: http://www.gnu.org/copyleft/gpl.html

    Clustering enabled: Spinning up 1 process(es).

    2018-08-03T07:02:57.812Z [32555] - info: Initializing NodeBB v1.10.1 http://nodebb.freeplaying.it

    2018-08-03T07:02:57.816Z [32555] - verbose: * using redis store at 127.0.0.1:6379

    2018-08-03T07:02:57.817Z [32555] - verbose: * using themes stored in: /var/www/html/nodebb.freeplaying.it/nodebb/node_modules

    2018-08-03T07:03:00.048Z [32555] - verbose: [minifier] utilizing a maximum of 1 additional threads

    2018-08-03T07:03:00.084Z [32555] - verbose: Checking dependencies for outdated modules

    2018-08-03T07:03:00.806Z [32555] - verbose: [notifications.init] Registering jobs.

    2018-08-03T07:03:00.808Z [32555] - verbose: [user/jobs] (Re-)starting user jobs...

    2018-08-03T07:03:00.810Z [32555] - verbose: [user/jobs] Starting job (digest.daily)

    2018-08-03T07:03:00.812Z [32555] - verbose: [user/jobs] Starting job (digest.weekly)

    2018-08-03T07:03:00.814Z [32555] - verbose: [user/jobs] Starting job (digest.monthly)

    2018-08-03T07:03:00.815Z [32555] - verbose: [user/jobs] Starting job (reset.clean)

    2018-08-03T07:03:00.815Z [32555] - verbose: [user/jobs] 4 jobs started

    2018-08-03T07:03:00.816Z [32555] - verbose: [emailer] Setting up SMTP fallback transport

    2018-08-03T07:03:00.869Z [32555] - verbose: [emailer] Built custom email templates

    2018-08-03T07:03:00.870Z [32555] - info: [themes] Using theme nodebb-theme-persona

    2018-08-03T07:03:00.871Z [32555] - verbose: [plugins] Initializing plugins system

    2018-08-03T07:03:00.880Z [32555] - verbose: [plugins] Loaded plugin: nodebb-plugin-composer-default

    2018-08-03T07:03:00.925Z [32555] - verbose: [plugins] Loaded plugin: nodebb-plugin-markdown

    2018-08-03T07:03:01.026Z [32555] - verbose: [plugins] Loaded plugin: nodebb-plugin-mentions

    2018-08-03T07:03:01.030Z [32555] - verbose: [plugins] Loaded plugin: nodebb-widget-essentials

    2018-08-03T07:03:01.034Z [32555] - verbose: [plugins] Loaded plugin: nodebb-rewards-essentials

    2018-08-03T07:03:01.035Z [32555] - verbose: [plugins] Found 3 sound file(s) for plugin nodebb-plugin-soundpack-default

    2018-08-03T07:03:01.036Z [32555] - verbose: [plugins] Loaded plugin: nodebb-plugin-soundpack-default

    2018-08-03T07:03:01.136Z [32555] - verbose: [plugins] Loaded plugin: nodebb-plugin-emoji

    2018-08-03T07:03:01.163Z [32555] - verbose: [plugins] Loaded plugin: nodebb-plugin-emoji-android

    2018-08-03T07:03:01.166Z [32555] - verbose: [plugins] Loaded plugin: nodebb-plugin-redactor-center

    2018-08-03T07:03:01.310Z [32555] - verbose: [plugins] Loaded plugin: nodebb-plugin-dbsearch

    2018-08-03T07:03:01.548Z [32555] - verbose: [plugins] Loaded plugin: nodebb-plugin-emailer-mailgun
    2018-08-03T07:03:01.691Z [32555] - verbose: [plugins] Loaded plugin: nodebb-plugin-ns-embed

    2018-08-03T07:03:01.696Z [32555] - verbose: [plugins] Loaded plugin: nodebb-plugin-spam-be-gone

    2018-08-03T07:03:01.713Z [32555] - verbose: [plugins] Loaded plugin: nodebb-plugin-sso-facebook

    2018-08-03T07:03:01.733Z [32555] - verbose: [plugins] Loaded plugin: nodebb-plugin-sso-twitter

    2018-08-03T07:03:01.735Z [32555] - info: [plugins] Plugins OK

    2018-08-03T07:03:01.735Z [32555] - verbose: [plugins/fireHook] static:assets.prepare

    2018-08-03T07:03:01.736Z [32555] - verbose: [plugins/fireHook] static:app.preload

    2018-08-03T07:03:01.736Z [32555] - verbose: [plugins/fireHook] filter:hotswap.prepare

    2018-08-03T07:03:01.781Z [32555] - verbose: [plugins/fireHook] static:app.load

    2018-08-03T07:03:01.816Z [32555] - verbose: [plugins/fireHook] action:markdown.updateParserRules

    2018-08-03T07:03:01.825Z [32555] - info: [plugins/spam-be-gone] Settings loaded

    3/8 09:03 [32555] - verbose: [plugins/embed] Updating rules...

    3/8 09:03 [32555] - verbose: [plugins/embed] Updating rule list, total rules: 0

    2018-08-03T07:03:01.828Z [32555] - verbose: [hotswap] Router with id plugins replaced successfully

    2018-08-03T07:03:01.828Z [32555] - verbose: [plugins] All plugins reloaded and rerouted

    2018-08-03T07:03:01.829Z [32555] - verbose: [plugins/fireHook] filter:auth.init

    2018-08-03T07:03:01.842Z [32555] - verbose: [hotswap] Router with id auth replaced successfully

    2018-08-03T07:03:01.843Z [32555] - info: Routes added

    2018-08-03T07:03:01.854Z [32555] - verbose: [meta/blacklist] Loading 0 blacklist rule(s)

    2018-08-03T07:03:01.855Z [32555] - verbose: [plugins/fireHook] filter:flags.getFilters

    2018-08-03T07:03:01.855Z [32555] - info: NodeBB Ready

    2018-08-03T07:03:01.859Z [32555] - verbose: [plugins/fireHook] action:nodebb.ready

    2018-08-03T07:03:01.860Z [32555] - info: Enabling 'trust proxy'

    2018-08-03T07:03:01.873Z [32555] - info: NodeBB is now listening on: 0.0.0.0:4567

    and everything seems fine.

    Any ideas?

  • 0 Votes
    4 Posts
    2k Views

    awesome bro will check it out thank you