- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
目前我有提供 SSE 作为服务的程序,我必须在 IIS 上部署。但它不能正常工作,这是我在没有 IIS 的情况下运行 .exe 时的结果。
data: Hello, world
但是当它在 IIS 后面运行时,浏览器卡在加载中。我必须刷新事件 Hello, world
数千次才能使 IIS 刷新结果到浏览器,它会立即刷新,而不是像 SSE 过去那样进行增量更新。
这是我的web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath=".\sse_server.exe"
arguments="-port=%HTTP_PLATFORM_PORT% -environment development"
stdoutLogEnabled="false"
requestTimeout="00:05:00"
stdoutLogFile=".\sse_server_log">
</httpPlatform>
<urlCompression doStaticCompression="true" doDynamicCompression="false" />
<caching enabled="false" enableKernelCache="false" />
</system.webServer>
</configuration>
这是我的go
代码
func SSEHello(rw http.ResponseWriter, flusher http.Flusher) {
rw.Header().Set("Content-Type", "text/event-stream; charset=utf-8")
rw.Header().Set("Cache-Control", "no-cache")
rw.Header().Set("Connection", "keep-alive")
rw.WriteHeader(http.StatusOK)
for i := 0; i < 1000; i++ {
rw.Write([]byte("data:Hello, world\n\n"))
flusher.Flush()
time.Sleep(time.Millisecond * 100)
}
}
最佳答案
实际上HttpPlatformHandler 有8kb output buffer ,所以我的消息没有立即发送出去。
我必须改变HttpPlatformHandler to ASP.NET Core Module ,所以 web.config
必须更新到这个。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath=".\sse_server.exe" />
</system.webServer>
</configuration>
要在 iis
上以 aspNetCore
启动 go
的应用程序,应用程序需要获取环境变量名称 ASPNETCORE_PORT
然后在该端口上启动 http 服务。
port := os.Getenv("ASPNETCORE_PORT")
http.ListenAndServe(":"+port, nil)
就是这样!
关于go - 如何为服务器发送事件(SSE、EventStream)配置 IIS 的 HTTPPlatformHandler,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52517156/
我将 SSE 与 EventStream 一起用于 javascript 的内置逻辑。当 onopen 返回成功结果时,onmessage 回调不起作用。奇怪的是,在 Chrome 中的 EventS
我正在使用 PlayFramework 2.5.3 并想创建一个 akka.stream.scaladsl.Source来自 akka.event.EventStream (事件流是参与者系统的一部分
ReactFX 中的 EventStream 是否有任何功能可以缓存最后一个值,以便可以将其重播给新订阅者? RxJava Observable 有很多程序来完成此类任务。我希望 EventStrea
假设我的代码中有一个任意值:var 任意值 = null; 我的代码中有多个地方可以更改此值。我可以创建一个基于 this 值变化的 EventStream 吗?换句话说,如果 arbitraryVa
这个问题可能是针对ReactFX的创建者的,但欢迎其他人回答。 我目前开始在 JavaFX 应用程序中使用 ReactFX 进行数据共享和事件处理。我的问题是一个类如何订阅来监听来自两个(或更多)不同
所有示例都使用 Ramda 作为 _(很清楚示例上下文中的方法做什么)和 kefir 作为 frp (与 bacon.js 中的 API 几乎相同) 我有一个流,它描述了位置的变化。 var xDel
主题:我有一个流(实际上是 Bacon.interval 的组合流和按钮单击 EventStreams),它触发 ajax 请求并解决手动和自动数据刷新的任务。 问题:在手动事件(单击按钮)之后,我需
我想定期轮询 url 并以流的形式获取结果。我可能遗漏了一些明显的东西,但有谁知道如何在 bacon.js 中做这个看似简单的事情吗? 最佳答案 明白了,这将每 5 秒轮询一次 /whatever 并
我正在尝试使用 Bacon.js 制作一个简单的 Canvas 绘图应用程序。它应该允许通过像这样使用鼠标单击选择起点和终点来绘制一条线。 points = paper.asEventStream('
下面 NeDB 上的 Node 回调工作正常, Datastore = require 'nedb' db = new Datastore db.insert a: 'Hi!', (err, docs
我正在尝试理解 FRP 概念并使用 bacon.js 构建图像 slider 。我正在映射 next 按钮(顺便说一句,这是一个人为的示例)点击流,如下所示: var position = $slid
socket.io 上的事件绑定(bind)正常工作, io = require('socket.io')() io.on 'connection', (socket) -> console.
这就是我如何使用 bacon.js 从常规 DOM 节点获取 EventStream: var el = document.getElementById('input1'); var stream =
我是 Bacon.js 的新手,我正在努力弄清楚它是如何工作的。那么,有没有一种方法可以使用变量,例如来自 URL 的哈希值,就好像它是 onVariableChange 事件的 EventStrea
我将更频繁地使用 RxJava 和 ReactFX,但我想了解的是如何协调两者,因为 ReactFX 没有 RxJava 依赖项,那么两者如何在同一个 monad 中相互通信?对于在没有大量样板的情况
目前我有提供 SSE 作为服务的程序,我必须在 IIS 上部署。但它不能正常工作,这是我在没有 IIS 的情况下运行 .exe 时的结果。 data: Hello, world 但是当它在 IIS 后
我在我的网站上将 SignalR 与服务器发送的事件一起使用,我能够在 Chrome 中通过单击请求然后选择 EventStream 选项卡使用开发人员选项卡很好地调试它。 但最近发生了一些奇怪的事情
我尝试将 ibm-eventstreams-dev v 0.1.1 安装到 IBM Cloud Private 中,但收到一条错误消息: 内部服务错误:图表与 Tiller v2.6.0 不兼容 最佳
作为引用,这个问题源于 Scala method performance (collect or foreach or other) looping through sockets? 我在一个acto
我正在为使用 boto3 的 s3 客户端函数“select_object_content”从 S3 存储桶读取对象的函数创建单元测试。我想要模拟的响应是 { 'Payload': Event
我是一名优秀的程序员,十分优秀!