新人:关于Error: Request aborted
发布于 4个月前 作者 sayfly 263 次浏览 来自 问答

Error: Request aborted at IncomingMessage.onReqAborted (/home/witmob/chatrobot/node_modules/express/node_modules/connect/node_modules/multiparty/index.js:131:17) at IncomingMessage.emit (events.js:92:17) at abortIncoming (http.js:1911:11) at Socket.serverSocketCloseListener (http.js:1923:5) at Socket.emit (events.js:117:20) at TCP.close (net.js:465:12) POST /v1?command=chat 400 120008ms 上面是错误提示 我起了个定时器输入一个数a 每隔a秒请求一次 如果输入的数大于80就会报这个错
求大神告诉为什么会出现这个错误

4 回复

大哥,我觉得你应该发代码上来大家才能帮你看看哪里出问题噢?

function sendMsg(sendId, receiverId, message, msgNumb, times, type, height1, width1, msgType, audioTime, callback) { var time = new Date(); var count = 0; var flg = 0; console.log(“”); userProvider.findOne({userId: sendId}, {}, function (err, result) { if (err) { callback({code: 1, err: err}); } else { console.log("type==>>", type); if (type == “person”) { var times1 = setInterval(function () { var json = {"chatFrom": sendId, "deviceId": sendId, "time": time.Format(‘yyyy-MM-dd hh:mm:ss’), "msgType": msgType, "msgID": Date.now().toString(), "msg": message, "isUploading": false, "isTop": 0, "isSystem": false, "isSuccuss": true, "isSucc": false, "isSend": false, "number": 0, "isSelect": false, "isRead": false, "isPlay": false, "isNote": true, "isMy": false, "isGroup": false, "unReadNum": 0, "isForceUpdate": false, "height": height1, "voicePlay": false, "audioTime": audioTime, "width": width1, "code": 0} var sendMsg = JSON.stringify(json); var msgLength = sendMsg.length; if (msgLength % sectionNum == 0) { count = parseInt(msgLength / sectionNum); } else { count = parseInt(msgLength / sectionNum) + 1; } console.log("msgLength===>>>", msgLength, " count===>>>", count); var list = []; encryptMessage(0, count, sendMsg, publicKey, list, function () { var sendMessage; for (var i = 0; i < count; i++) { if (i == 0) { sendMessage = list[0]; } else { sendMessage = sendMessage + ‘,’ + list[i]; } } request.post(global.sendMessage + “&token=” + result.token, {rejectUnauthorized: false}, function (err, response, body) { if (err) { console.log("sendMsgError==", err); } else { console.log("sendMsgResult==", body); callback({code: 0, err: JSON.parse(body).message}); } }).form({senderId: sendId, receiverId: receiverId, message: sendMessage, msgType: "person", type: msgType, id: Date.now()}); flg++; if (flg == msgNumb) { clearInterval(times1); } }); }, times * 1000); } else if (type == “group”) { var times2 = setInterval(function () { var json = {"chatFrom": receiverId, "deviceId": sendId, "time": time.Format(‘yyyy-MM-dd hh:mm:ss’), "msgType": msgType, "msgID": Date.now().toString(), "msg": message, "isUploading": false, "isTop": 0, "isSystem": false, "isSuccuss": true, "isSucc": false, "isSend": false, "number": 0, "isSelect": false, "isRead": false, "isPlay": false, "isNote": true, "isMy": false, "isGroup": true, "unReadNum": 0, "isForceUpdate": false, "height": height1, "voicePlay": false, "audioTime": audioTime, "width": width1, "code": 0} var sendMsg = JSON.stringify(json); var msgLength = sendMsg.length; if (msgLength % sectionNum == 0) { count = parseInt(msgLength / sectionNum); } else { count = parseInt(msgLength / sectionNum) + 1; } console.log("msgLength===>>>", msgLength, " count===>>>", count); var list = []; encryptMessage(0, count, sendMsg, publicKey, list, function () { var sendMessage; for (var i = 0; i < count; i++) { if (i == 0) { sendMessage = list[0]; } else { sendMessage = sendMessage + ‘,’ + list[i]; } } request.post(global.sendMessage + “&token=” + result.token, {rejectUnauthorized: false}, function (err, response, body) { if (err) { console.log("sendMsgError==", err); } else { console.log("sendMsgResult==", body); callback({code: 0, err: JSON.parse(body).message}); } }).form({senderId: sendId, receiverId: receiverId, message: sendMessage, msgType: "group", type: msgType, id: Date.now() }); flg++; if (flg == msgNumb) { clearInterval(times2); } }); }, times * 1000); } } })

};

function encryptMessage(i, count, message, publickey, list, callback) { if (i == count) { callback(); } else { var str = message.substring(i * sectionNum, (i + 1) * sectionNum); console.log("str====", str); var encryptedStr = publickey.encrypt(str, 'utf8’, 'base64’, ursa.RSA_PKCS1_PADDING); list.push(encryptedStr); i++; encryptMessage(i, count, message, publickey, list, callback); } };

这个是请求的代码

回到顶部