在我的nodejs
express
项目中,我正在尝试设置有关错误的电子邮件。使用winston
& winston-mail
pkgs
我收到以下错误:
{
"date": "Wed May 17 2017 12:36:54 GMT+0530 (IST)",
"process": { "pid": 22443, "uid": 502, "gid": 20, "cwd": "/Users/shezad/workspace/goblin", "execPath": "/usr/local/Cellar/node/7.8.0/bin/node", "version": "v7.8.0", "argv": ["/usr/local/Cellar/node/7.8.0/bin/node", "/Users/shezad/workspace/goblin/server.js"], "memoryUsage": { "rss": 52514816, "heapTotal": 37646336, "heapUsed": 24661328, "external": 698215 } },
"os": { "loadavg": [1.8125, 1.763671875, 1.7275390625], "uptime": 1126961 },
"trace": [{
"column": 13,
"file": "/Users/shezad/workspace/goblin/node_modules/emailjs/smtp/error.js",
"function": "module.exports",
"line": 3,
"method": "exports",
"native": false
}, {
"column": 29,
"file": "/Users/shezad/workspace/goblin/node_modules/emailjs/smtp/response.js",
"function": "TLSSocket.error",
"line": 26,
"method": "error",
"native": false
}, {
"column": 20,
"file": "events.js",
"function": "emitOne",
"line": 101,
"method": null,
"native": false
}, {
"column": 7,
"file": "events.js",
"function": "TLSSocket.emit",
"line": 191,
"method": "emit",
"native": false
}, {
"column": 8,
"file": "net.js",
"function": "emitErrorNT",
"line": 1284,
"method": null,
"native": false
}, {
"column": 11,
"file": "internal/process/next_tick.js",
"function": "_combinedTickCallback",
"line": 80,
"method": null,
"native": false
}, {
"column": 9,
"file": "internal/process/next_tick.js",
"function": "process._tickCallback",
"line": 104,
"method": "_tickCallback",
"native": false
}],
"stack": ["Error: connection encountered an error",
" at module.exports (/Users/shezad/workspace/goblin/node_modules/emailjs/smtp/error.js:3:13)",
" at TLSSocket.error (/Users/shezad/workspace/goblin/node_modules/emailjs/smtp/response.js:26:29)",
" at emitOne (events.js:101:20)",
" at TLSSocket.emit (events.js:191:7)",
" at emitErrorNT (net.js:1284:8)",
" at _combinedTickCallback (internal/process/next_tick.js:80:11)",
" at process._tickCallback (internal/process/next_tick.js:104:9)"
],
"level": "error",
"message": "uncaughtException: connection encountered an error",
"timestamp": "2017-05-17T07:06:54.696Z"
}
我的logger.js文件如下:
var logger = new(winston.Logger)({
transports: [
new(winston.transports.Console)({colorize:true}),
new(winston.transports.File)(config.logging.file_options),
new(winston.transports.Mail)(config.logging.mail_options)
],
exceptionHandlers: [
new (winston.transports.Mail)(config.logging.mail_options)
]
});
日志记录的配置就是这样
config.logging = {
file_options: {
name: 'app-log',
filename: './logs/app.log',
level: 'info',
timestamp: true,
colorize: true,
handleExceptions: true,
humanReadableUnhandledException: true,
prettyPrint: true,
json: true,
maxsize: 512 * 1024
},
mail_options: {
to: ['dummy@blackbuck.com'],
from: '***@blackbuck.com',
subject: format('[{0}]', config.stage_name.toUpperCase()) + ' {{level}} : {{msg}}',
host: 'smtp.gmail.com',
port: 587,
username: '***@blackbuck.com',
password: '******',
ssl: true,
prettyPrint: true,
}
};
有人可以解释一下这个错误是什么吗?以及如何纠正它? 谢谢广告
答案 0 :(得分:0)
我设法通过删除port: 587
我还是不知道为什么? :|