简体   繁体   English

Node.js Socket.io Heroku“没有方法'Configure'”

[英]Node.js Socket.io Heroku “no method 'Configure'”

I'm trying to get socket.io set up on Heroku, so I have this code on my main script: 我试图在Heroku上设置socket.io,因此我的主脚本中包含以下代码:

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

io.configure(function () { 
  io.set("transports", ["xhr-polling"]); 
  io.set("polling duration", 10);
});

When I try to run, I get the following error: 当我尝试运行时,出现以下错误:

TypeError: Object #(Object) has no method 'configure'

I have Socket.io in the dependencies, and I've tried adding a .listen() but then I get a "has no method 'listeners' error. 我在依赖项中有Socket.io,并且尝试添加.listen(),但随后出现“没有方法“监听器”错误。

Your help is much appreciated. 非常感谢您的帮助。

Try this: 尝试这个:

var io = require('socket.io').listen(8080);

io.configure(function () { 
  io.set("transports", ["xhr-polling"]); 
  io.set("polling duration", 10);
});

You trying to configure wrong object. 您试图配置错误的对象。 Method listen creates Socket.IO instance. 方法listen创建Socket.IO实例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM