2016-09-22 139 views
0

我使用nodejs(0.12)和express(3.1.0)。 我的服务器保存了一段时间运行完美,但一些次后,就开始给400(坏请求),并保持它给400对接下来的所有请求nodejs服务器提供错误的请求(400)错误。为什么?

message: "Error: Bad Request 
at SendStream.error (/var/www/storehippo/node_modules/express/node_modules/send/lib/send.js:145:16) 
at SendStream.pipe (/var/www/storehippo/node_modules/express/node_modules/send/lib/send.js:298:31) 
at Object.static (/var/www/storehippo/node_modules/express/node_modules/connect/lib/middleware/static.js:83:8) 
at Object.handle (eval at eval at wrapHandle (/var/www/storehippo/node_modules/newrelic/lib/instrumentation/connect.js:1:0)) 
at /var/www/storehippo/node_modules/express/node_modules/connect/lib/proto.js:199:15 
at /var/www/storehippo/node_modules/newrelic/lib/transaction/tracer/index.js:157:28 
at Object.<anonymous> (/var/www/storehippo/dist/dist_17-09-2016_10:20:03/app/index.js:252:5) 
at Object.handle (eval at eval at wrapHandle (/var/www/storehippo/node_modules/newrelic/lib/instrumentation/connect.js:1:0)) 
at /var/www/storehippo/node_modules/express/node_modules/connect/lib/proto.js:199:15 
at /var/www/storehippo/node_modules/newrelic/lib/transaction/tracer/index.js:157:28" 

为了修复它,我必须重新启动我的服务器和无法找到它的根本原因。

如何找到根本原因并解决它?

+1

您需要提供比这更多的信息。 –

+0

请为我们提供一些解决问题的代码。 –

+0

@ravishankar恩?你解决了吗? – rsp

回答

1

首先,您正在使用节点0.12 - 当前LTS版本(推荐用于所有用途)是4.5.0,当前版本是6.6.0(6.x将在下个月变为LTS)。您可能会考虑升级Node,因为您使用的是过时的版本。 0.12的维护期将在几个月内结束,然后将不再获得任何更新,请参阅:https://github.com/nodejs/LTS#lts_schedule

您使用的Express模块​​也非常过时。最新的3.x是我认为3.21.2和当前版本的Express是4.14.0。

现在,如果您想查找问题,那么您应该从查看/var/www/storehippo/dist/dist_17-09-2016_10:20:03/app/index.js的第252行开始,因为这似乎是您自己的代码在该堆栈跟踪中的唯一行。其他线路似乎都是外部模块,但问题可能在于其中一个模块。

可能有很多原因,为什么你的服务器表现良好,然后开始行为不当 - 你可能有一些内存泄漏,一些资源没有被释放并在一段时间后枯竭,你可能会改变你的应用程序的某些状态导致其他请求失败等。

不幸的是,您没有包含任何可以帮助您发现问题的信息。