【问题标题】:Node.js on Windows Azure IIS using IISNode: How to setup node-inspector debugger?使用 IISNode 在 Windows Azure IIS 上的 Node.js:如何设置节点检查器调试器?
【发布时间】:2015-10-19 15:12:07
【问题描述】:

问题 #1

当我使用http://127.0.0.1/mysite/node/server.js URL 时,它会显示我的测试页面,这没问题。但我希望它在我使用http://127.0.0.1/mysite/node/server.js/debug/ URL 时向我显示基于节点检查器的调试页面。但是,这不起作用,而是继续向我显示相同的示例页面内容。

我应该怎么做才能使调试器工作?

问题 #2

另外,我注意到当我访问这个 URL 时,它会自动被重定向到

http://127.0.0.1/mysite/ public/mysite/ node/server.js/debug/

为什么会这样?我可以避免这种重定向吗?如果是,怎么做?

Web.config 内容

  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />


<!-- Web.Debug.config adds attributes to this to enable remote debugging when publishing in Debug configuration. -->
<!--<iisnode watchedFiles="web.config;*.js"/>--> 

<!-- Remote debugging (Azure Website with git deploy): Comment out iisnode above, and uncomment iisnode below. -->
<iisnode watchedFiles="web.config;*.js"
  loggingEnabled="true"
  devErrorsEnabled="true"
  nodeProcessCommandLine="node.exe &#45;&#45;debug"/>

<!-- indicates that the server.js file is a Node.js application 
to be handled by the iisnode module -->
<handlers>
    <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
    <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
    <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
    <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
    <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
    <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />

    <add name="iisnode" path="node/server.js" verb="*" modules="iisnode" />

    <!-- Remote debugging (Azure Website with git deploy): Uncomment NtvsDebugProxy handler below.
    Additionally copy Microsoft.NodejsTools.WebRole to 'bin' from the Remote Debug Proxy folder.-->
    <add name="NtvsDebugProxy" path="ntvs-debug-proxy/95a6beca-6da8-493c-b380-2822603aa5dc" verb="*" resourceType="Unspecified"
    type="Microsoft.NodejsTools.Debugger.WebSocketProxy, Microsoft.NodejsTools.WebRole"/>
</handlers>

<rewrite>
  <rules>
    <clear />

    <rule name="LogFile" patternSyntax="ECMAScript" stopProcessing="true">
      <match url="^[a-zA-Z0-9_\-]+\.js\.logs\/\d+\.txt$"/>
    </rule>

    <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="node/server.js"/>
    </rule>

  </rules>
</rewrite>
<!-- <rewrite>
  <rules>
    <clear />
    <!- Remote debugging (Azure Website with git deploy): Uncomment the NtvsDebugProxy rule below. ->
    <!-<rule name="NtvsDebugProxy" enabled="true" stopProcessing="true">
      <match url="^ntvs-debug-proxy/.*"/>
    </rule>->
    <rule name="app" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
      <match url="iisnode.+" negate="true" />
      <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
      <action type="Rewrite" url="server.js" />
    </rule>
  </rules>
</rewrite> -->
  </system.webServer>

【问题讨论】:

  • 你的开发环境是什么?你身边的 IIS 和 OS 是哪个版本?您是否使用适用于 Node.js 的 Azure 云服务?

标签: node.js azure iis iisnode


【解决方案1】:

问题 #1

根据您的描述,您似乎在本地主机或 Azure VM 上调试和测试您的项目。在这种情况下,我们应该确保 IIS 首先安装了 IISNode 模块。所以我建议你可以参考这个document来确保你已经成功安装了IISNode。
其次,我们应该检查项目是否包含您的节点检查器配置。你也可以使用 Node.js Sample 来检查你的 node-inspector 是否安装成功。 第三,如果您不能使用此调试器,您可以按“F12”在启用 Webkit 的 Web 浏览器中跟踪调试器错误。如果您遇到错误,请在论坛上分享错误并获得进一步支持。

问题 #2

对于第二个问题,似乎是 URL rewrite Rule 导致了这个错误的 URL。

<rule name="StaticContent">
      <action type="Rewrite" url="public{REQUEST_URI}"/>
</rule>

例如,如果对该 URL 发出请求:“http://127.0.0.1/content/default.aspx?tabid=2&subtabid=3”,则 REQUEST_URI 服务器变量包含 content/default.aspx?tabid=2&subtabid=3。

您可以得到“http://127.0.0.1/public/content/default.aspx?tabid=2&subtabid=3”作为结果。 我建议你可以参考这个URL rewrite module了解更多详情。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-02-11
    • 2013-12-17
    • 1970-01-01
    • 1970-01-01
    • 2016-07-31
    • 1970-01-01
    • 2014-10-28
    • 2014-04-04
    相关资源
    最近更新 更多