我正在尝试使用'nntp' package for节点向usenet上的一个组发布一条消息。我不能让这个例子起作用,唯一对我有效的例子是“获取所有以‘alt.binaries’开头的新闻组的列表。”
上传示例代码:
var NNTP = require('nntp'),
inspect = require('util').inspect;
var c = new NNTP();
c.on('ready', function() {
var msg = {
from: { name: 'Node User', email: 'user@example.com' },
groups: 'alt.test',
subject: 'Just testing, do not mind me',
body: 'node.js rules!'
};
c.post(msg, function(err) {
if (err) throw err;
});
});
c.on('error', function(err) {
console.log('Error: ' + err);
});
c.on('close', function(had_err) {
console.log('Connection closed');
});
c.connect({
host: 'example.org',
user: 'foo',
password: 'bar'
});在上面的代码片段中,主机、用户和密码是不正确的,但我确信它们是正确的(我可以让其他示例使用这些设置)。
我得到的错误是:
/Develop/node/Usenet/node_modules/nntp/lib/nntp.js:662
this._debug('> ' + this._curReq.cmd + ' ' + this._curReq.params);
^
TypeError: Property '_debug' of object #<NNTP> is not a function如果我向c.connect中的对象添加调试函数,我会得到以下错误:
/Develop/node/Usenet/node_modules/nntp/lib/nntp.js:265
self._curReq.cb(undefined, code, retval, type);
^
TypeError: Property 'cb' of object #<Object> is not a function我使用的是node v0.10.32。我希望有人能帮帮我。谢谢,里克
发布于 2015-02-19 19:07:23
只需在连接时在options对象上添加"debug: function(){}“
var c = new NNTP();
c.on('ready', function() {
var msg = {
from: { name: 'Node User', email: 'user@example.com' },
groups: 'alt.test',
subject: 'Just testing, do not mind me',
body: 'node.js rules!'
};
c.post(msg, function(err) {
if (err) throw err;
});
});
c.on('error', function(err) {
console.log('Error: ' + err);
});
c.on('close', function(had_err) {
console.log('Connection closed');
});
c.connect({
host: 'example.org',
user: 'foo',
password: 'bar',
debug: function(){}
});https://stackoverflow.com/questions/26867483
复制相似问题