簡體   English   中英

使用IISNode的Windows Azure IIS上的Node.js:如何設置節點檢查器調試器?

[英]Node.js on Windows Azure IIS using IISNode: How to setup node-inspector debugger?

問題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>

問題#1

根據您的描述,您似乎在本地主機或Azure VM上調試和測試了項目。 在這種情況下,我們應確保IIS首先安裝了IISNode模塊 因此,我建議您可以參考本文檔以確保已成功安裝IISNode。
其次, 我們應該檢查項目是否包括您的node-inspector配置 您還可以使用Node.js Sample來檢查是否已成功安裝Node-inspector。 第三,如果無法使用此調試器,則可以在支持Webkit的Web瀏覽器中按“ F12”以跟蹤調試器錯誤 如果遇到錯誤,請在論壇上分享該錯誤,並尋求進一步的支持。

問題#2

對於第二個問題,似乎URL重寫規則導致了該錯誤的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重寫模塊以獲取更多詳細信息。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM