Corro la mia app Node.js e ho avuto un grosso errore
iisnode encountered an error when processing the request.
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.
The node.exe process has not written any information to stderr or iisnode was unable to capture this information. Frequent reason is that the iisnode module is unable to create a log file to capture stdout and stderr output from node.exe. Please check that the identity of the IIS application pool running the node.js application has read and write access permissions to the directory on the server where the node.js application is located. Alternatively you can disable logging by setting system.webServer/iisnode/@loggingEnabled element of web.config to "false".
Alcuni dicono che l'errore è da env.Port altri dicono che è da webconfig che ho bisogno di impostare su server.js, l'ho già impostato, anche se lo cancello ho avuto gli stessi errori.
Ho provato con iis client per impostare le autorizzazioni
In 3 giorni non riesco a capire cosa ho fatto di sbagliato, ho provato con e senza web.cofig. Mi sto perdendo qualcosa ? Anche la connessione a MongoDB viene impostata con la stringa fornita dal portale di Azure.
risposte:
0 per risposta № 1Sono in grado di riprodurre esattamente lo stesso errore.
Ecco il mio server.js
:
const express = require("express")
const app = express()
app.get("/", function (req, res) {
res.send("Hello World!")
})
app.listen(3000)
In web.config
, Ho questo:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.webServer>
<webSocket enabled="false" />
<handlers>
<add name="iisnode" path="server.js" verb="*" modules="iisnode" />
</handlers>
<rewrite>
<rules>
<rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^server.js/debug[/]?" />
</rule>
<rule name="StaticContent">
<action type="Rewrite" url="public{REQUEST_URI}" />
</rule>
<rule name="DynamicContent">
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True" />
</conditions>
<action type="Rewrite" url="server.js" />
</rule>
</rules>
</rewrite>
<security>
<requestFiltering>
<hiddenSegments>
<remove segment="bin" />
</hiddenSegments>
</requestFiltering>
</security>
<httpErrors existingResponse="PassThrough" />
<iisnode
watchedFiles="web.config;*.js"
node_env="%node_env%"
loggingEnabled="true"
logDirectory="iisnode"
debuggingEnabled="true"
maxLogFileSizeInKB="1048"
maxLogFiles="50"
devErrorsEnabled="true" />
</system.webServer>
</configuration>
Con queste configurazioni, posso visitare https://{mysitename}.scm.azurewebsites.net/api/vfs/site/wwwroot/iisnode/index.html
per vedere l'errore dettagliato.
Dopo aver cambiato app.listen(3000)
a app.listen(process.env.PORT || 3000)
, L'ho fatto funzionare.
Maggiori informazioni su questo: