0

我正在开发一个 .NET 应用程序,它通过事件源与 JS 客户端通信。

它工作得很好,但我有一个问题:

如果客户端在服务器写入时断开连接,服务器会一直卡住 10 秒,最后给我一个错误:

The remote host closed the connection. The error code is 0x80070079.

这个错误是正常的,我抓住了它,但我想避免 10 秒或至少将其限制在 1 或 2 秒。

我的代码是这样的:

 if (ctx.Response.IsClientConnected)
 {
      ctx.Response.Write("data: " + e.json + "\n\n");
 }

我尝试了,<httpRuntime executionTimeout="3"/>但它不起作用......

任何想法?

瓦伦丁 :)

4

1 回答 1

0

I think there might be a need for a minimum timeout based on connections' unreliability.

I don't know your code logic and architecture exactly but you can convert your operations to work asynchronously.

于 2013-01-02T20:10:57.833 回答