Socket.io configuration error

I am using socket.io v.1.0.3.

and try to tune for production.

  var io = require('socket.io')(server);

            io.configure('production', function()
            {
                log(" set config for production");
                io.enable('browser client minification'); // send minified client
                io.enable('browser client etag'); // apply etag caching logic based on version number
                io.enable('browser client gzip'); // gzip the file
                io.set('log level', 1); // reduce logging
                io.set('transports', [ // enable all transports (optional if you want flashsocket)
                    'websocket', 'flashsocket', 'htmlfile', 'xhr-polling', 'jsonp-polling'
                ]);
            });

Error indicating socket.io instance does not have configure

       io.configure('production', function()
               ^
TypeError: Object #<Server> has no method 'configure'

How?

Thank.

+4
source share
1 answer

I ran into this problem while trying to run the application on a hero, since the hero does not allow you to use websockets atm. Setting the transport protocol in the on event worked for me.

io.on('connection', function () {
  io.set("transports", ["xhr-polling"]);
  io.set("polling duration", 10);
});
+1
source

Source: https://habr.com/ru/post/1542858/


All Articles