简体   繁体   English

Node.JS 应用程序将在 localhost 上运行,但不会通过 iisnode 在 URL 上运行

[英]Node.JS application will run on localhost but not URL via iisnode

I have a node.js application that runs fine when I go to localhost:3000, however when I try and access it via the url using iisnode, it returns the following.我有一个 node.js 应用程序,当我 go 到 localhost:3000 时运行良好,但是当我尝试通过 url 使用 iisnode 访问它时,它返回以下。

iisnode encountered an error when processing the request. iisnode 在处理请求时遇到错误。

HRESULT: 0x2 HTTP status: 500 HTTP subStatus: 1002 HTTP reason: Internal Server Error You are receiving this HTTP 200 response because system.webServer/iisnode/@devErrorsEnabled configuration setting is 'true'. HRESULT: 0x2 HTTP status: 500 HTTP subStatus: 1002 HTTP reason: Internal Server Error You are receiving this HTTP 200 response because system.webServer/iisnode/@devErrorsEnabled configuration setting is 'true'.

In addition to the log of stdout and stderr of the node.exe process, consider using debugging and ETW traces to further diagnose the problem.除了node.exe进程的stdout和stderr的日志,考虑使用debugging和ETW traces来进一步诊断问题。

The last 64k of the output generated by the node.exe process to stderr is shown below: node.exe进程生成到stderr的output最后64k如下图:

Warning: connect.session() MemoryStore is not designed for a production environment, as it will leak memory, and will not scale past a single process.警告:connect.session() MemoryStore 不是为生产环境设计的,因为它会泄漏 memory,并且不会扩展到单个进程。 Pipe production requires elevated privileges Pipe 生产需要提升权限

Do you mean you could access the node.js application directly on the server, but if you use the IP address it throw the error?你的意思是你可以直接在服务器上访问 node.js 应用程序,但是如果你使用 IP 地址它会抛出错误?

For the warning, it seems that you hve used the MemoryStore to store the session.对于警告,您似乎已经使用 MemoryStore 来存储 session。 MemoryStore is just for development mode, it may cause this issue. MemoryStore 仅用于开发模式,可能会导致此问题。

I suggest you could try to use cookie-session package.我建议您可以尝试使用cookie-session package。

To do this simply install cookie-session:为此,只需安装 cookie-session:

npm install cookie-session

Then in your app.js, find where express-session is being used and replace with cookie-session.然后在您的 app.js 中,找到使用 express-session 的位置并替换为 cookie-session。

app.use(require('cookie-session')({
    // Cookie config, take a look at the docs...
}));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM