Configure TimeOut and Transports in Socket.IO 1.0

2020-03-04 09:25发布

In old versions of Socket.IO (< 0.9), I configured "close timeout" and "transports" this way:

io.set("transports", ["xhr-polling"]);
io.set("close timeout", 3);

But now, the command io.set has been deprecated. How do I define close timeout and transports?

When I use the old version this message appears:

Option close timeout is not valid.

1条回答
Anthone
2楼-- · 2020-03-04 09:29

See the documentation here: http://socket.io/docs/migrating-from-0-9/#configuration-differences

Basically, you just have to set those when you initialize the server:

var socket = require('socket.io')({
  // options go here
});
查看更多
登录 后发表回答