Attempting to stream using eventource via nginx / fastcgi

I am trying to set up an event stream using MVC.NET, Nginx and Fastcgi. The thread works fine for me using xsp4, but I was not able to get it to work through Nginx and Fastcgi. My goal is to open the EventSource stream and move the data to my site.

I tried to add the module 'ngx_http_upstream_keepalive' - http://wiki.nginx.org/HttpUpstreamKeepaliveModule - which is funny because there is a “Note - this will not work with HTTP streams up” in the module description. But wait, isn't that the name of the module? In any case, maybe I'm confused here. I also tried adding "proxy_buffering off" to my nginx.conf, which also did not help.

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

Please help me StackOverflow!

+5
source share
1 answer

Based on what I read here:

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

you need to disable X-Accel-Buffering. Here is a sample 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();
}

Hope the above code fixes your problem.

+6
source

All Articles