lextudio / httpplatformhandlerv2

HttpPlatformHandler v2

Home Page:https://docs.lextudio.com/blog/httpplatformhandler-v2/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't seem to get working with NodeJS (Empty log file and generic page error)

josh-hemphill opened this issue · comments

commented

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Following the basic configuration for httpplatformhandler results in error: HTTP Error 502.5 - HttpPlatformHandler Startup Failure on the page, and empty log files.

Expected Behavior

No response

Steps To Reproduce

I created a basic setup and got the errors.

web.config:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="httpPlatformHandler"
        path="*"
        verb="*"
        modules="httpPlatformHandler"
        resourceType="Unspecified"
        requireAccess="Script" />
    </handlers>
    <httpPlatform stdoutLogEnabled="true"
      stdoutLogFile=".\node"
      startupTimeLimit="2000"
      startupRetryCount="5"
      rapidFailsPerMinute="5"
      processPath="C:\Users\j1rob\AppData\Local\pnpm\node.exe"
      arguments="server.js"
      processesPerApplication="1">
      <environmentVariables>
        <environmentVariable name="PORT"
          value="%HTTP_PLATFORM_PORT%" />
        <environmentVariable name="NODE_ENV"
          value="Production" />
      </environmentVariables>
      <!-- <recycleOnFileChange>
      <file path=".\server.js" />
      </recycleOnFileChange> -->
    </httpPlatform>
  </system.webServer>
</configuration>

Basic node server:

const { createServer } = require('node:http');
const hostname = '127.0.0.1';
const port = process.env.PORT ? parseInt(process.env.PORT) : 3000;
const server = createServer((req, res) => {
	res.statusCode = 200;
	res.setHeader('Content-Type', 'text/plain');
	res.end('Hello World');
});
server.listen(port, hostname, () => {
	console.log(`Server running at http://${hostname}:${port}/`);
});

Exceptions (if any)

No response

.NET Version

8

Anything else?

No response

commented

Although I just tried changing the exe to a normally installed node.exe under Program Files/nodejs/node.exe and that got me slightly farther. The page is still giving the generic error, but now the log file shows:


node:internal/fs/utils:353
    throw err;
    ^

Error: EPERM: operation not permitted, lstat 'E:\Share'
    at Object.realpathSync (node:fs:2691:7)
    at toRealPath (node:internal/modules/helpers:55:13)
    at Module._findPath (node:internal/modules/cjs/loader:697:22)
    at resolveMainPath (node:internal/modules/run_main:26:23)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:24)
    at node:internal/main/run_main_module:28:49 {
  errno: -4048,
  syscall: 'lstat',
  code: 'EPERM',
  path: 'E:\\Share'
}

Node.js v21.1.0
commented

I gave IIS permissions to the folder I was using using, but it's complaining about the root of the drive, so I'm not sure what's going on.

What kind of drive is it? Keep in mind IIS does not support any type of mapped drives.

commented

Ah, event viewer gives me

Application '/LM/W3SVC/2/ROOT' with physical root 'E:\Share\dev\api\' failed to start process with commandline
'"C:\Users\j1rob\AppData\Local\pnpm\node.exe" ./dist/cli/run.js start' with multiple retries.
Failed to bind to port '18128'. First 30KB characters of captured stdout and stderr logs from multiple retries
Process Id: 15212. 
   File Version: 18.0.24105.3. Description: IIS HttpPlatformHandler Module V2 Request Handler. Commit:

But nothing I've found on the internet seems to give any leads as to what could be causing this.

commented

It's one of my only normal physical drives. a 1TB SSD. The reason it's labeled share is because it has sharing turned on.

There is little this repo (of HttpPlatformHandler) can help, as the crash is on Node.js side and no documentation is there to explain why it says "Error: EPERM: operation not permitted, lstat 'E:\Share'". To investigate further, you might debug into Node.js source code.

Close it now.