【问题标题】:Node.js Azure Web App Windows 500.1001 ErrorNode.js Azure Web 应用程序 Windows 500.1001 错误
【发布时间】:2017-08-29 08:12:52
【问题描述】:

我在 Windows 上有一个 Azure Web 应用程序,它运行 iisnode 以与我的 Node 应用程序通信,我收到一个 500 错误,子状态为 1001。似乎 IIS 似乎没有从 Node.js 获得响应。我在应用程序设置下设置了 NODE_ENV 和 PORT 变量。为了最小化变量,我还将其简化为 Node Hello World 应用程序。据我所知,Node 获取 PORT 变量并使用正确的端口启动,因为我看到标准输出表明应用程序在指定的端口上启动。但是,当我尝试任何请求时,Node 似乎从未真正收到来自 iisnode 的请求。如果我尝试 console.log 一条消息,我什么也得不到,而且我没有看到任何异常,如果它是在事情的响应方面,我希望是这种情况。我已经以相同的方式设置了其他应用程序服务,这似乎工作正常。我尝试从其中一个部署代码,但我得到了相同的行为。

我正在尝试使用以下代码进行最基本的测试

    var http = require('http');

    // Configure our HTTP server to respond with Hello World to all requests.
    var server = http.createServer(function (request, response) {
      console.log('Getting Response');
      response.writeHead(200, {"Content-Type": "text/plain"});
      response.end("Hello World\n");
    });

    var port = process.env.PORT || '3003';
    server.listen(port);

    // Put a friendly message on the terminal
    console.log("Server running on port " + port);

我收到了Server running on port 8080 的回复,这让我相信服务器可以正常启动。但是,我只是在浏览器中得到友好的 500.1001 响应。从我的角度来看,当它的设置与我们正在运行的许多其他网站相同时,有什么想法会导致这种情况吗?

【问题讨论】:

    标签: node.js azure


    【解决方案1】:

    Azure Web Apps 仅支持端口 80 用于 HTTP 和端口 443 用于 HTTPS 流量。为避免此错误,您需要从 Application Settings 中删除 PORT 变量设置,因为 Azure 已在变量 process.env.PORT 中传递了一个端口,它不是真正的端口号,而是像 \\.\pipe\(guid...) 这样的管道。见Node Js RestFull API on Azure,Returns HTTP Error 500.1001 - Internal Server Error

    【讨论】:

    • 所以这行得通,但这是最近的变化吗?我不确定为什么我的所有其他 Web 应用程序都通过以相同方式指定节点端口来工作。基本上,我不确定其他那些现在是如何工作的。
    猜你喜欢
    • 2020-07-18
    • 1970-01-01
    • 1970-01-01
    • 2017-11-22
    • 2023-03-17
    • 1970-01-01
    • 2018-01-12
    • 2022-10-01
    • 1970-01-01
    相关资源
    最近更新 更多