1

I am working on a complex asp.net application using aspx web pages. In one of these pages, I need to display 15 minutes of video file in a popup page.

I am using HTTP 206 partial content approach and streaming large mp4 file using OutputStream of HttpResponse. The video plays fine. I have different services running in the background which are also using HTTP port. These services must be updated and therefore sending Get messages. We also maintain sessions and heart beat service continuously checks the application status and forces login after it does not receive response for sometime. As soon as video starts playing, the HTTP port seem to lock and so all above communication seem blocked. This results in hanging of the application.

Is this common behavior? What I need to do to maintain other services while video is playing?

Thanks in advance.

  • Why do you think it's Chrome causing the problem? Have you tried other browsers, like Firefox or Opera, and they do not exhibit the problem? Sounds like ASP.NET Session State is not being handled correctly and so blocks other requests until previous requests release their locks (or finish). – AlwaysLearning Jul 26 '19 at 16:56
  • Thanks for your reply AlwaysLearning . We have requirement to use only latest chrome browser so I have not tested behavior on other browsers. You may be right about handling of ASP.NET Session State. How can I make sure that ASP.NET Session State handles such situation correctly? Any reference which discusses such situation will be helpful. Thanks! – Muhammad Khan Jul 26 '19 at 17:42
  • I have used EnableSessionState=”false” for the page but I don't see any change in behavior. – Muhammad Khan Jul 26 '19 at 17:49

2 Answers2

0

Given that you used EnableSessionState="false" with a capital E it sounds like you tried to change that setting from a code behind page. Session State will already have been created in a read-write state (by default) and have locks in place for the current request, so it's too late to change the setting from there.

Turning off Session State, for the current IIs Application, can be achieved by adding the enableSessionState setting to the web.config file:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.web>
    <pages enableSessionState="false" />
  </system.web>
</configuration>

Alternatively, for the specific page(s) that don't need Session State, you can add the @ENABLESESSIONSTATE processing directive to their first line:

<%@ ENABLESESSIONSTATE=False %>

If this is an ASP.NET MVC application you can also decorate specific controller classes with a Session State Attribute to apply a particular Session State Behavior:

using System.Web.Mvc;

namespace Foo.Bar.Baz
{
    [SessionState(SessionStateBehavior.ReadOnly)]
    public class HomeController : Controller
    {
    //...
    }
}

You may need to do this for several pages - not just the pop-up window with the MP4 video streaming in it but also the page that invokes it.

If this solves your problem please don't forget to mark it as an answer.

AlwaysLearning
  • 7,915
  • 5
  • 27
  • 35
  • Thanks for taking out your time and thanks for your suggestions. I am already aware of such solutions. I had gone through https://stackoverflow.com/questions/3629709/i-just-discovered-why-all-asp-net-websites-are-slow-and-i-am-trying-to-work-out and similar stuff already. I think a feature enhancement should not dictate a redesign of whole application. My question was related to "HTTP Partial Response". Using webrtc approach where a different port is used for video streaming, the issue does not come up. Sessions are needed for "Keep Alive" functionality for asp.net web forms. – Muhammad Khan Jul 29 '19 at 13:27
0

I ended up using Janus WebRTC Server (https://janus.conf.meetecho.com/) and FFMPEG to solve the issue. The idea is to stream content of mp4 file to a designated RTP port. The ffmpeg process was started using following C# code.

var filePath = "abc.mp4"; // Replace it with exact path to the file

Process ffmpegProcess = new Process();

var fileName = ConfigurationManager.AppSettings["FFMPEGEXEPath"]; // location of FFMPEG exe

                        var serverAddress = string.Empty;

                        IPHostEntry ipHostInfo = Dns.GetHostEntry(Dns.GetHostName());

                        foreach (IPAddress address in ipHostInfo.AddressList)
                        {
                            if (address.AddressFamily == AddressFamily.InterNetwork)
                            {
                                serverAddress = address.ToString() + "8004";
                                break;
                            }
                        }

                        var ffmpegParams = " -threads 2 -re -y -i " + filePath + " -an -vcodec libx264 -r 30  -threads:0 16 -tune zerolatency -preset ultrafast -f rtp rtp://" + serverAddress;
                        ffmpegProcess.StartInfo.FileName = "cmd.exe";
                        ffmpegProcess.StartInfo.CreateNoWindow = true;
                        ffmpegProcess.StartInfo.UseShellExecute = false;
                        ffmpegProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                        ffmpegProcess.StartInfo.Arguments = @"/k " + fileName + " " + ffmpegParams;
                        ffmpegProcess.Start();

I am looking forward to HTTP 206 partial content approach if someone can provide solution to my problem in the context mentioned in the original question.