Node.js Azure Web 应用程序 Windows 500.1001 错误

标签 node.js azure

我在 Windows 上有一个 Azure Web 应用程序,它运行 iisnode 来与我的 Node 应用程序进行通信,但我收到了子状态为 1001 的 500 错误。 IIS 似乎没有收到 Node 的响应。我已经在“应用程序设置”下设置了 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 响应。从我的角度来看,当它的设置与我们正在运行的许多其他网站相同时,您有什么想法可能会导致这种情况吗?

最佳答案

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

关于Node.js Azure Web 应用程序 Windows 500.1001 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45921289/

相关文章:

node.js - 所有 nodejs 事件 API 的任何文档?

javascript - 在 discord.js 中发送文件缓冲区

node.js - Nodejs 异步/等待嵌套 API 进度

javascript - 用nodejs在文件上写http请求

Django 将 azure-storage 形式的 blob 返回为可下载文件

javascript - 无法使 grunt-postcss 和 autoprefixer 工作

azure - Azure DevOps 中的应用程序服务名称显示未找到结果

c# - 调试IIS随机疯狂内存使用情况

ios - 通过应用程序进行 Azure B2C Facebook 注册

azure - 使用 Azure Functions 时是否有任何合理的时钟偏差假设?