尝试通过 nginx/fastcgi 使用 eventsource 进行流式传输

发布于 2024-12-01 13:09:51 字数 516 浏览 2 评论 0原文

我正在尝试使用 MVC.NET、Nginx 和 Fastcgi 设置事件流。使用 xsp4 的流媒体工作正常,但我无法通过 Nginx 和 Fastcgi 使其工作。我的目标是打开 EventSource 流并将下游数据传输到我的网站。

我尝试添加“ngx_http_upstream_keepalive”模块 - http://wiki.nginx.org/HttpUpstreamKeepaliveModule - 这很有趣,因为有模块描述中的“注意 - 这不适用于 HTTP 上游”。但是等等,这不是模块的名称吗?无论如何,也许我在这里很困惑。我还尝试将“proxy_buffering off”添加到我的 nginx.conf 中,但这也没有帮助。

我知道这应该很容易做到,但我不知所措。我可以在 nginx.conf 中添加一些属性来使其工作吗?或者是否需要在.NET 的响应中添加一些内容?

请帮助我 StackOverflow!

I am trying to set up an event stream using MVC.NET, Nginx and Fastcgi. The streaming works fine for me using xsp4, but I have not been able to get it to work through Nginx and Fastcgi. My goal is to open an EventSource stream and to downstream data to my website.

I have tried adding the 'ngx_http_upstream_keepalive' module - http://wiki.nginx.org/HttpUpstreamKeepaliveModule - which is funny because there is "Note - this This will not work with HTTP upstreams" in the module description. But wait, isn't that the name of the module? Anyways, maybe I'm confused here. I have also tried adding 'proxy_buffering off' to my nginx.conf, which also hasn't helped.

I understand this should be fairly easy to do, but I am at a loss. Is there some property I can add to my nginx.conf to make this work? Or is there something to add to the Response in .NET?

Please help me StackOverflow!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

樱花坊 2024-12-08 13:09:51

根据我在这里读到的内容:

http://wiki.nginx.org/X-accel

您需要关闭X-加速缓冲。这是一些示例代码:

public ActionResult Stream(string id)
{
    Response.ContentType = "text/event-stream";
    Response.Buffer = false;
    Response.BufferOutput = false;
    Response.Headers["X-Accel-Buffering"] = "no";
    return View();
}

希望上面的代码可以解决您的问题。

Based on what I have read here:

http://wiki.nginx.org/X-accel

you need to turn off X-Accel-Buffering. Here is some example code:

public ActionResult Stream(string id)
{
    Response.ContentType = "text/event-stream";
    Response.Buffer = false;
    Response.BufferOutput = false;
    Response.Headers["X-Accel-Buffering"] = "no";
    return View();
}

Hopefully the code above fixes your problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文