Home > front end >  Node. Js pressure test times wrong BadRequestError: request aborted
Node. Js pressure test times wrong BadRequestError: request aborted

Time:09-27

Specific error message:
 BadRequestError: request aborted 
At IncomingMessage. OnAborted (d: \ nodeJs - hwsoft \ node_modules \ body - parser \ node
_modules \ raw - body \ index js: 231:10)
The at emitNone (events. Js: 67:13)
The at IncomingMessage. Emit (events. Js: 166:7)
The at abortIncoming (_http_server. Js: 280:11)
Ats Socket. ServerSocketCloseListener (_http_server. Js: 293:5)
The at emitOne (events. Js: 82:20)
Ats Socket. Emit (events. Js: 169:7)
The at TCP. _onclose (net. Js: 477:12)


Server. Js code:
 var express=the require (' express '); 
Var url=the require (' url ');
Var fs=the require (" fs ");
Var HTTP=the require (" HTTP ");
Var the queryString=the require (' the queryString);
Var bodyParser=the require (' body parser - ');

Var app=express ();

App. Use (bodyParser. Json ({limit: '1000 KB'}));
App. Use (bodyParser. Urlencoded ({limit: '1000 KB, extended: true}));

Var count=0;

App. Post ('/upload. Node ', function (the req, resp) {
//the console. The log (the req)
//the console log (the req. Body);
Var Data=https://bbs.csdn.net/topics/new Buffer (the req. Body. FileData, 'base64);
//the console. The log (Data);
Var filePath=the req. Body. FilePath.
//the console log (the req. Body);
Var response={};

Var writerStream=fs. CreateWriteStream (" D:/pdftest1/"+ + +". PDF "+ count);

WriterStream. Write (Data);

//marks the end of the file
WriterStream. End ();

WriterStream. On (' finish ', function () {
The console. The log (" writing, ");
});

WriterStream. On (' error ', function (err) {
The console. The log (err. Stack);
});
//fs. WriteFile (filePath, Data, function (err) {
//if (err) {
//response={
//"MSG" : 'error'
//};
//}
//response={
//"MSG" : 'success'
//};
//the console. The log (' uploaded successfully! ');
//});
The console. The log (' * * * '+ count +' * * * ');
Resp. The status (200). The end ();
});

Var server=app. Listen (20001, function () {

The console. The log (' Server started. ');
})


Server. Js business is receiving a json string, there is a PDF file stream of bytes (BASE64 encoding), when the pressure reaches a certain pressure measurement, and error
BadRequestError: request aborted.

To solve this is what reason is caused,

CodePudding user response:

I also had the same problem. Please ask the landlord to solve it,
BadRequestError: request aborted
The at IncomingMessage. Emit (events. Js: 182:13)
The at abortIncoming (_http_server. Js: 444:9)
The at socketOnClose (_http_server. Js: 437:3)
Ats Socket. Emit (events. Js: 187:15)
The at TCP. _handle. Close (net. Js: 599:12)

CodePudding user response:

To solve the problem, please? I have encountered the same problem
  • Related