简体   繁体   中英

iisnode encountered an error when processing the request

I'm trying to check angularjs app with a server side written in node js and this is an error i get when i run in by webmatrix

iisnode encountered an error when processing the request.

 HRESULT: 0x2 HTTP status: 500 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'.

Does somebody know how to fix it?

Your application pool doesn't seem to have enough permissions to write to the current folder.

  1. You can either edit the permissions to give the IIS_IUSRS group write permissions to that folder

  2. Go into the advanced settings menu and under Process Model -> Identity change the user account to a user that already has write permissions.

It looks like your iisnode cannot write its log file, perhaps because it does not have write permissions. If you have access to to the server then you can check inside the app's folder for an iisnode folder, that is where iisnode tries to write its logs by default.

Until you get this log info you are stuck because the 500 error you are seeing only tells you that the error has occurred on the server somewhere. You need the logs to give you the info you need to proceed.

The only other alternative is to run the whole thing locally and use something like node-inspector (I use grunt-node-inspector ) to debug into the nodeJS code to see what is happening.

I fixed this issue by running the setupsamples.bat file. This adds the permissions and other necessary configuration. The path is C:\\Program Files\\iisnode\\setupsamples.bat for me

Allow, 'Full Control', for user 'IIS_IUSRS', from 'Advanced Security' upon right clicking you'r application root directory.

Reference

For me there were no permissions problem because when I did console.log() in the server I got the log in the iisnode forlder.

I put all the Express in a try code block and in the try I used logged the exception, I have found out that for some reason iisnode lookup in dist/dist/index.html instead of dist/index.html

Once I have fixed that the error, everything have been solved.

When I try to run the server I had three problems.I solved this:

  1. Instead of writing port by hand such as 3000, I added process.env.PORT . It determined its port by itself.

  2. Giving permissions to write log folder. I solved this by making logginEnabled="false" on my web.config file.

  3. Removing console.log() commands. It regards outputs as an error.

index.js

const express = require("express");
const app = express();
var path = require("path");
const port = process.env.PORT;

app.get("/", (req, res) => {
  res.send({ appName: "animal-cdn" });
});

app.use(express.static(path.join(__dirname, "public")));
app.listen(port, () => {
  // console.log(`Example app listening at http://localhost:${port}`);
});

web.config file:

<configuration>
    <system.webServer>
    
        <validation validateIntegratedModeConfiguration="false" />
        <!-- indicates that the server.js file is a node.js application 
        to be handled by the iisnode module -->
         <iisnode 
                 loggingEnabled="false"
                 debuggingEnabled="true"
              />

        <handlers>
            <add name="iisnode" path="index.js" verb="*" modules="iisnode"/>
        </handlers>
        
        <rewrite>
            <rules>
                <rule name="myapp">
                    <match url="/*" />
                    <action type="Rewrite" url="index.js" />
                </rule>
                <rule name="HTTPS Redirect" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions>
                        <add input="{HTTPS}" pattern="^OFF$" />
                    </conditions>
                    <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" appendQueryString="false" />
                </rule>
            </rules>
        </rewrite>

    </system.webServer>
</configuration>

I fix this to give full control to IIS_IURS in iss >select app>edit permission>add>find IIS_IURS>give full control this works for me

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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