错误:发送后无法设置标头?

时间:2017-11-08 06:44:06

标签: javascript node.js

我对Node.js很新,我遇到了一些问题。

在我尝试订阅时出现此错误:

  

_http_outgoing.js:489       抛出新错误('在发送后无法设置标头。');       ^

     

错误:发送后无法设置标头。       在validateHeader(_http_outgoing.js:489:11)       在ServerResponse.setHeader(_http_outgoing.js:496:3)       在服务器上。 (/root/node_modules/isin/iSiN.js:26:18)       在emitTwo(events.js:125:13)       在Server.emit(events.js:213:7)       at parserOnIncoming(_http_server.js:602:12)       在HTTPParser.parserOnHeadersComplete(_http_common.js:116:23)

这是我的服务器端脚本:

var architect = require('neataptic').architect;
var http = require('http');
var url = require('url');
var answer;
var trainingData = new Array();
var roll_prophecy, roll_realy = 0;
var input_prophecy, output_prophecy;
const server = http.createServer(function (request, response) {
const queryData = url.parse(request.url, true).query;
response.writeHead(200, {"Content-Type": "text/plain"});
if (queryData.param) {
const land = neuralnetwork(queryData.param);
response.end(answer);
} else {
response.end('Ошибка - пустой запрос.');
}
});
server.listen(8001);
var narx = new architect.NARX(1, [5, 5, 5], 1, 20, 20);
function neuralnetwork (iSin) {
answer = prediction(iSin).toString();
return answer;
};
function prediction(roll_realy) {
if(trainingData.length<100){
trainingData.push({input: [roll_prophecy], output: [roll_realy]});
}
else{
trainingData.shift();
trainingData.push({input: [roll_prophecy], output: [roll_realy]});
}
narx.train(trainingData, {
log: 10000,
iterations: 5000,
error: 0.00003,
rate: 0.1
});
for (var i in trainingData) {
var input = trainingData[i].input;
var output = Math.round(narx.activate(input));
}
for (var i = 0; i < 100; i++) {
input_prophecy = output_prophecy;
output_prophecy = Math.round(narx.activate([input_prophecy]));
}
roll_prophecy = output_prophecy;
return roll_prophecy;
};

0 个答案:

没有答案