Delaying sockets start



  • 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?


  • Global Moderator

    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.


Log in to reply
 

Suggested Topics

| |