使用 HttpPlatformHandler 在 IIS 上托管的 Suave 应用关闭连接
Suave App Hosted on IIS with HttpPlatformHandler Closes Connection
我正在尝试使用 HttpPlatformHandler(版本 1.2)在 IIS (IIS 10.0) 中获取基本的 Suave 应用程序 运行ning。
当我拥有它时 return 单个 WebPart,例如
(OK "Hello World")
IIS 中的应用程序 运行 正常,我可以在 http://localhost/testapp 通过名称向它发出请求(testapp 是默认网站下的应用程序名称)。
但是,如果我为 WebPart 使用更复杂的东西,例如
let app =
choose
[ GET >=> choose
[ path "/hello" >=> OK "Hello GET"
path "/goodbye" >=> OK "Good bye GET" ]
POST >=> choose
[ path "/hello" >=> OK "Hello POST"
path "/goodbye" >=> OK "Good bye POST" ] ]
网站启动了,但我无法通过应用程序名称访问它。但是我仍然可以通过港口到达它。
当我按名称点击应用程序时,我收到了 HTTP 503.2(网关错误)响应。
应用程序是从 HttpPlatformHandler 执行的 FAKE 脚本启动的。
对于上下文,这是启动应用程序的 FAKE 脚本:
#r "./tools/FakeLib.dll"
#r "Suave.dll"
open System
open Suave
open Suave.Successful
open Fake
open System.Net
open Suave.Filters
open Suave.Sockets
open Suave.Operators
open System.IO
Environment.CurrentDirectory <- __SOURCE_DIRECTORY__
let port = Sockets.Port.Parse <| getBuildParamOrDefault "port" "8083"
let serverConfig =
{ defaultConfig with
logger = Logging.Loggers.saneDefaultsFor Logging.LogLevel.Verbose
bindings = [ HttpBinding.mk HTTP IPAddress.Loopback port ]
}
let app =
choose
[ GET >=> choose
[ path "/hello" >=> OK "Hello GET"
path "/goodbye" >=> OK "Good bye GET" ]
POST >=> choose
[ path "/hello" >=> OK "Hello POST"
path "/goodbye" >=> OK "Good bye POST" ] ]
startWebServer serverConfig (OK "Hello")
//startWebServer serverConfig app
以上脚本按预期工作。但是,如果我使用 app
WebPart
而不是 (OK "Hello")
我会遇到上述问题。
为了完整起见,这里 web.config 为 HttpPlatformHandler 设置:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<remove name="httpplatformhandler" />
<add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform
stdoutLogEnabled="true" startupTimeLimit="20"
processPath=".\tools\FAKE.exe"
arguments=".\test.fsx port=%HTTP_PLATFORM_PORT%" >
<environmentVariables>
</environmentVariables>
</httpPlatform>
</system.webServer>
</configuration>
我查看了日志,但遗憾的是我看不到任何表明错误的信息。
我已经检查了事件查看器,可能出现问题的唯一线索是应用程序日志中的以下信息事件:
The description for Event ID 1001 from source HttpPlatformHandler cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.
这是应用程序按预期执行 运行(没有 choose
)的日志的一部分:
[V] 2016-01-19T02:43:40.6932823Z: initialising BufferManager with 827392 bytes [Suave.Socket.BufferManager]
[I] 2016-01-19T02:43:40.7114149Z: listener started in 20.885 ms with binding 127.0.0.1:18450 [Suave.Tcp.tcpIpServer]
[V] 2016-01-19T02:43:40.8146603Z: 127.0.0.1 connected, total: 1 clients [Suave.Tcp.job]
[V] 2016-01-19T02:43:40.8166665Z: reserving buffer: 811008, free count: 99 [Suave.Tcp.job] [Suave.Socket.BufferManager]
[V] 2016-01-19T02:43:40.8217965Z: -> processor [Suave.Web.httpLoop.loop]
[V] 2016-01-19T02:43:40.8228181Z: reading first line of request [Suave.Web.processRequest]
[V] 2016-01-19T02:43:40.8378128Z: reserving buffer: 802816, free count: 98 [Suave.Web.readMoreData] [Suave.Socket.BufferManager]
[V] 2016-01-19T02:43:40.8498033Z: reading headers [Suave.Web.processRequest]
[V] 2016-01-19T02:43:40.8776578Z: freeing buffer: 802816, free count: 99 [Suave.Web.split] [Suave.Socket.BufferManager]
[V] 2016-01-19T02:43:40.8866594Z: parsing post data [Suave.Web.processRequest]
[V] 2016-01-19T02:43:40.8886553Z: <- processor [Suave.Web.httpLoop.loop]
[V] 2016-01-19T02:43:40.9057610Z: 'Connection: keep-alive' recurse [Suave.Web.httpLoop.loop]
[V] 2016-01-19T02:43:40.9057610Z: -> processor [Suave.Web.httpLoop.loop]
[V] 2016-01-19T02:43:40.9057610Z: reading first line of request [Suave.Web.processRequest]
[V] 2016-01-19T02:43:40.9057610Z: reserving buffer: 802816, free count: 98 [Suave.Web.readMoreData] [Suave.Socket.BufferManager]
[V] 2016-01-19T02:43:45.2531307Z: reading headers [Suave.Web.processRequest]
[V] 2016-01-19T02:43:45.2541141Z: freeing buffer: 802816, free count: 99 [Suave.Web.split] [Suave.Socket.BufferManager]
[V] 2016-01-19T02:43:45.2541141Z: parsing post data [Suave.Web.processRequest]
[V] 2016-01-19T02:43:45.2541141Z: <- processor [Suave.Web.httpLoop.loop]
[V] 2016-01-19T02:43:45.2551164Z: 'Connection: keep-alive' recurse [Suave.Web.httpLoop.loop]
这是日志的一部分,其中应用程序无法按预期运行(通过 choose
进行路由):
[V] 2016-01-19T02:44:59.6356127Z: initialising BufferManager with 827392 bytes [Suave.Socket.BufferManager]
[I] 2016-01-19T02:44:59.6537478Z: listener started in 20.987 ms with binding 127.0.0.1:18708 [Suave.Tcp.tcpIpServer]
[V] 2016-01-19T02:44:59.8848907Z: 127.0.0.1 connected, total: 1 clients [Suave.Tcp.job]
[V] 2016-01-19T02:44:59.8879891Z: reserving buffer: 811008, free count: 99 [Suave.Tcp.job] [Suave.Socket.BufferManager]
[V] 2016-01-19T02:44:59.8929862Z: -> processor [Suave.Web.httpLoop.loop]
[V] 2016-01-19T02:44:59.8939749Z: reading first line of request [Suave.Web.processRequest]
[V] 2016-01-19T02:44:59.9068548Z: reserving buffer: 802816, free count: 98 [Suave.Web.readMoreData] [Suave.Socket.BufferManager]
[V] 2016-01-19T02:44:59.9209857Z: reading headers [Suave.Web.processRequest]
[V] 2016-01-19T02:44:59.9259688Z: freeing buffer: 802816, free count: 99 [Suave.Web.split] [Suave.Socket.BufferManager]
[V] 2016-01-19T02:44:59.9338521Z: parsing post data [Suave.Web.processRequest]
[V] 2016-01-19T02:44:59.9378580Z: <- processor [Suave.Web.httpLoop.loop]
[V] 2016-01-19T02:44:59.9518518Z: freeing buffer: 811008, free count: 100 [Suave.Tcp.job] [Suave.Socket.BufferManager]
[V] 2016-01-19T02:44:59.9518518Z: Shutting down transport. [Suave.Tcp.job]
[V] 2016-01-19T02:44:59.9528516Z: 127.0.0.1 disconnected, total: 0 clients [Suave.Tcp.job]
当应用程序执行时,连接会打开,然后立即关闭。当我通过端口点击应用程序时,一个新连接打开然后立即(再次)关闭。
我是不是对应用程序的主机配置做错了什么,还是我在使用选择功能时遗漏了什么?任何帮助,将不胜感激。谢谢!
我认为路线应该是这样的:
path "/app/hello"
我正在尝试使用 HttpPlatformHandler(版本 1.2)在 IIS (IIS 10.0) 中获取基本的 Suave 应用程序 运行ning。
当我拥有它时 return 单个 WebPart,例如
(OK "Hello World")
IIS 中的应用程序 运行 正常,我可以在 http://localhost/testapp 通过名称向它发出请求(testapp 是默认网站下的应用程序名称)。
但是,如果我为 WebPart 使用更复杂的东西,例如
let app =
choose
[ GET >=> choose
[ path "/hello" >=> OK "Hello GET"
path "/goodbye" >=> OK "Good bye GET" ]
POST >=> choose
[ path "/hello" >=> OK "Hello POST"
path "/goodbye" >=> OK "Good bye POST" ] ]
网站启动了,但我无法通过应用程序名称访问它。但是我仍然可以通过港口到达它。
当我按名称点击应用程序时,我收到了 HTTP 503.2(网关错误)响应。
应用程序是从 HttpPlatformHandler 执行的 FAKE 脚本启动的。
对于上下文,这是启动应用程序的 FAKE 脚本:
#r "./tools/FakeLib.dll"
#r "Suave.dll"
open System
open Suave
open Suave.Successful
open Fake
open System.Net
open Suave.Filters
open Suave.Sockets
open Suave.Operators
open System.IO
Environment.CurrentDirectory <- __SOURCE_DIRECTORY__
let port = Sockets.Port.Parse <| getBuildParamOrDefault "port" "8083"
let serverConfig =
{ defaultConfig with
logger = Logging.Loggers.saneDefaultsFor Logging.LogLevel.Verbose
bindings = [ HttpBinding.mk HTTP IPAddress.Loopback port ]
}
let app =
choose
[ GET >=> choose
[ path "/hello" >=> OK "Hello GET"
path "/goodbye" >=> OK "Good bye GET" ]
POST >=> choose
[ path "/hello" >=> OK "Hello POST"
path "/goodbye" >=> OK "Good bye POST" ] ]
startWebServer serverConfig (OK "Hello")
//startWebServer serverConfig app
以上脚本按预期工作。但是,如果我使用 app
WebPart
而不是 (OK "Hello")
我会遇到上述问题。
为了完整起见,这里 web.config 为 HttpPlatformHandler 设置:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<remove name="httpplatformhandler" />
<add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform
stdoutLogEnabled="true" startupTimeLimit="20"
processPath=".\tools\FAKE.exe"
arguments=".\test.fsx port=%HTTP_PLATFORM_PORT%" >
<environmentVariables>
</environmentVariables>
</httpPlatform>
</system.webServer>
</configuration>
我查看了日志,但遗憾的是我看不到任何表明错误的信息。
我已经检查了事件查看器,可能出现问题的唯一线索是应用程序日志中的以下信息事件:
The description for Event ID 1001 from source HttpPlatformHandler cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.
这是应用程序按预期执行 运行(没有 choose
)的日志的一部分:
[V] 2016-01-19T02:43:40.6932823Z: initialising BufferManager with 827392 bytes [Suave.Socket.BufferManager]
[I] 2016-01-19T02:43:40.7114149Z: listener started in 20.885 ms with binding 127.0.0.1:18450 [Suave.Tcp.tcpIpServer]
[V] 2016-01-19T02:43:40.8146603Z: 127.0.0.1 connected, total: 1 clients [Suave.Tcp.job]
[V] 2016-01-19T02:43:40.8166665Z: reserving buffer: 811008, free count: 99 [Suave.Tcp.job] [Suave.Socket.BufferManager]
[V] 2016-01-19T02:43:40.8217965Z: -> processor [Suave.Web.httpLoop.loop]
[V] 2016-01-19T02:43:40.8228181Z: reading first line of request [Suave.Web.processRequest]
[V] 2016-01-19T02:43:40.8378128Z: reserving buffer: 802816, free count: 98 [Suave.Web.readMoreData] [Suave.Socket.BufferManager]
[V] 2016-01-19T02:43:40.8498033Z: reading headers [Suave.Web.processRequest]
[V] 2016-01-19T02:43:40.8776578Z: freeing buffer: 802816, free count: 99 [Suave.Web.split] [Suave.Socket.BufferManager]
[V] 2016-01-19T02:43:40.8866594Z: parsing post data [Suave.Web.processRequest]
[V] 2016-01-19T02:43:40.8886553Z: <- processor [Suave.Web.httpLoop.loop]
[V] 2016-01-19T02:43:40.9057610Z: 'Connection: keep-alive' recurse [Suave.Web.httpLoop.loop]
[V] 2016-01-19T02:43:40.9057610Z: -> processor [Suave.Web.httpLoop.loop]
[V] 2016-01-19T02:43:40.9057610Z: reading first line of request [Suave.Web.processRequest]
[V] 2016-01-19T02:43:40.9057610Z: reserving buffer: 802816, free count: 98 [Suave.Web.readMoreData] [Suave.Socket.BufferManager]
[V] 2016-01-19T02:43:45.2531307Z: reading headers [Suave.Web.processRequest]
[V] 2016-01-19T02:43:45.2541141Z: freeing buffer: 802816, free count: 99 [Suave.Web.split] [Suave.Socket.BufferManager]
[V] 2016-01-19T02:43:45.2541141Z: parsing post data [Suave.Web.processRequest]
[V] 2016-01-19T02:43:45.2541141Z: <- processor [Suave.Web.httpLoop.loop]
[V] 2016-01-19T02:43:45.2551164Z: 'Connection: keep-alive' recurse [Suave.Web.httpLoop.loop]
这是日志的一部分,其中应用程序无法按预期运行(通过 choose
进行路由):
[V] 2016-01-19T02:44:59.6356127Z: initialising BufferManager with 827392 bytes [Suave.Socket.BufferManager]
[I] 2016-01-19T02:44:59.6537478Z: listener started in 20.987 ms with binding 127.0.0.1:18708 [Suave.Tcp.tcpIpServer]
[V] 2016-01-19T02:44:59.8848907Z: 127.0.0.1 connected, total: 1 clients [Suave.Tcp.job]
[V] 2016-01-19T02:44:59.8879891Z: reserving buffer: 811008, free count: 99 [Suave.Tcp.job] [Suave.Socket.BufferManager]
[V] 2016-01-19T02:44:59.8929862Z: -> processor [Suave.Web.httpLoop.loop]
[V] 2016-01-19T02:44:59.8939749Z: reading first line of request [Suave.Web.processRequest]
[V] 2016-01-19T02:44:59.9068548Z: reserving buffer: 802816, free count: 98 [Suave.Web.readMoreData] [Suave.Socket.BufferManager]
[V] 2016-01-19T02:44:59.9209857Z: reading headers [Suave.Web.processRequest]
[V] 2016-01-19T02:44:59.9259688Z: freeing buffer: 802816, free count: 99 [Suave.Web.split] [Suave.Socket.BufferManager]
[V] 2016-01-19T02:44:59.9338521Z: parsing post data [Suave.Web.processRequest]
[V] 2016-01-19T02:44:59.9378580Z: <- processor [Suave.Web.httpLoop.loop]
[V] 2016-01-19T02:44:59.9518518Z: freeing buffer: 811008, free count: 100 [Suave.Tcp.job] [Suave.Socket.BufferManager]
[V] 2016-01-19T02:44:59.9518518Z: Shutting down transport. [Suave.Tcp.job]
[V] 2016-01-19T02:44:59.9528516Z: 127.0.0.1 disconnected, total: 0 clients [Suave.Tcp.job]
当应用程序执行时,连接会打开,然后立即关闭。当我通过端口点击应用程序时,一个新连接打开然后立即(再次)关闭。
我是不是对应用程序的主机配置做错了什么,还是我在使用选择功能时遗漏了什么?任何帮助,将不胜感激。谢谢!
我认为路线应该是这样的:
path "/app/hello"