Streaming video url,the remote host closed the connection

Discuss how to use and promote Web standards with the Mozilla Gecko engine.
Post Reply
jaisee
Posts: 14
Joined: February 12th, 2015, 2:48 am

Streaming video url,the remote host closed the connection

Post by jaisee »

I have written a sample app for streaming video url (.NET Framework 4.0) that gets files to a remote server(S3 Signed URL) using generic Handler(.ashx), and then play the handler response in a html5 video tag. Here is the main streaming s3 url code:

In ASPX Page

Code: Select all

<div><video width="500px" height="500px" src="http://localhost:62489/Handler.ashx" autoplay="autoplay" controls="controls"></video>


Generic Handler(.ashx)

Code: Select all

public void ProcessRequest(HttpContext context)
{
    try
    {
        HttpRequest Request = context.Request;
        //Assign S3 URl
        string OrginalUrl = "https://s3.amazonaws.com/test/1gb.mp4";//input sample url
        System.Net.HttpWebRequest wreq = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(OrginalUrl);
        wreq.Method = System.Net.WebRequestMethods.Http.Get;
        wreq.ReadWriteTimeout = System.Threading.Timeout.Infinite;
        wreq.Timeout = System.Threading.Timeout.Infinite;
        wreq.KeepAlive = false;
        wreq.ProtocolVersion = System.Net.HttpVersion.Version10;
        using (System.Net.HttpWebResponse wresp = (System.Net.HttpWebResponse)wreq.GetResponse())
        {
            using (Stream mystream = wresp.GetResponseStream())
            {
                using (BinaryReader reader = new BinaryReader(mystream))
                {
                    Int64 length = Convert.ToInt32(wresp.ContentLength);
                    context.Response.Clear();
                    context.Response.Buffer = false;
                    context.Response.BufferOutput = false;
                    context.Response.AddHeader("Content-Type", "application/octet-stream");
                    context.Response.AddHeader("Content-Length", length.ToString());
                    byte[] buffer = new byte[1024];
                    while (true)
                    {
                        int bytesRead = mystream.Read(buffer, 0, buffer.Length);
                        if (bytesRead == 0) break;
                        if (context.Response.IsClientConnected)
                        {
                            context.Response.OutputStream.Write(buffer, 0, bytesRead);
                            context.Response.OutputStream.Flush();
                        }
                    }
                }
            }
        }

    }
    catch (Exception e)
    {
    }
}


My application works properly for all small files, but I get the following error when I try to send larger files (1 GB).I looked into my application log file, and was able to given the following info:

Exception :The remote host closed the connection. The error code is 0x800703E3

System.Web.Hosting.IIS7WorkerRequest.RaiseCommunicationError(Int32 result, Boolean throwOnDisconnect)
System.Web.Hosting.IIS7WorkerRequest.ExplicitFlush()
System.Web.HttpResponse.Flush(Boolean finalFlush)
System.Web.HttpResponse.Flush()
System.Web.HttpWriter.WriteFromStream(Byte[] data, Int32 offset, Int32 size)
System.Web.HttpResponseStream.Write(Byte[] buffer, Int32 offset, Int32 count)
ProcessRequest(HttpContext context) in d:\test\Handler\Handler.ashx.cs:line 60


The failure occurs 7 minutes after I call request.GetResponse() the remote connection was closed.
Note:This issue occurs only in Firefox above 35.0.it's working on upto Firefox 34.0.1 and other browsers(chrome,IE11).
Please help me,how to fix this issue? :( :( :(
Last edited by rsx11m on February 12th, 2015, 6:32 pm, edited 2 times in total.
Reason: put code into actual [code] to preserve indentation
rsx11m
Moderator
Posts: 14404
Joined: May 3rd, 2007, 7:40 am
Location: US

Re: Streaming video url,the remote host closed the connectio

Post by rsx11m »

Moved to Web Development.
jaisee
Posts: 14
Joined: February 12th, 2015, 2:48 am

Re: Streaming video url,the remote host closed the connectio

Post by jaisee »

Hi,
Have you found any other solution?

Thanks
jaisee
Posts: 14
Joined: February 12th, 2015, 2:48 am

Re: Streaming video url,the remote host closed the connectio

Post by jaisee »

Hi,
I'm getting struck to move further steps this issue.
Please let me know if you have fix to update.

I'm looking forward to your reply.

Thanks,
rsx11m
Moderator
Posts: 14404
Joined: May 3rd, 2007, 7:40 am
Location: US

Re: Streaming video url,the remote host closed the connectio

Post by rsx11m »

Apparently nobody has an idea/suggestion, thus no response yet... :-(
User avatar
trolly
Moderator
Posts: 39851
Joined: August 22nd, 2005, 7:25 am

Re: Streaming video url,the remote host closed the connectio

Post by trolly »

Wait ...
You get this error on the server side?

Mixing all information I know it may be possible that you send the wrong number of bytes in the HTTP header. And then the client disconnects when the given number of bytes are received.

Purely guessing.

PS:

Code: Select all

Int64 length = Convert.ToInt32(wresp.ContentLength);
...
context.Response.AddHeader("Content-Length", length.ToString());

This looks a bit strange to me.

PPS:
HttpWebResponse.ContentLength is of type Int64, then you convert it to a Int32 (truncating the value to less than 2G or exactly 2G depending on truncation operation) and then assign it back to an Int64.
Why not:

Code: Select all

context.Response.AddHeader("Content-Length", wresp.ContentLength.ToString());
Think for yourself. Otherwise you have to believe what other people tell you.
A society based on individualism is an oxymoron. || Freedom is at first the freedom to starve.
Constitution says: One man, one vote. Supreme court says: One dollar, one vote.
jaisee
Posts: 14
Joined: February 12th, 2015, 2:48 am

Re: Streaming video url,the remote host closed the connectio

Post by jaisee »

Hi.
Thanks for your response.

we have changed our code with the code you have mentioned HttpWebResponse.ContentLength,

Code: Select all

context.Response.AddHeader("Content-Length", wresp.ContentLength.ToString());


But we are still facing the same problem, please note this issue occurs only in firefox starting from the version 35 in both windows and MAc and we haven't faced this issue in earlier version of firefox.
Please provide me a suitable solution in order to fix this issue.

Thanks,
JC
Last edited by jaisee on March 25th, 2015, 5:40 am, edited 1 time in total.
User avatar
trolly
Moderator
Posts: 39851
Joined: August 22nd, 2005, 7:25 am

Re: Streaming video url,the remote host closed the connectio

Post by trolly »

I do not know what is wrong. I did not write that code.
Please provide all headers as sent to Firefox 34 and Firefox 35 and the real length of the transmission.
And also a Wireshark log which shows the packets around the disconnect.

I'm a debugging and analyse specialist (at least sort of) and I need to see real data to find out what is wrong.
Think for yourself. Otherwise you have to believe what other people tell you.
A society based on individualism is an oxymoron. || Freedom is at first the freedom to starve.
Constitution says: One man, one vote. Supreme court says: One dollar, one vote.
Dom1953
Posts: 52
Joined: July 24th, 2014, 6:02 am
Location: Australia

Re: Streaming video url,the remote host closed the connectio

Post by Dom1953 »

Trolly, it struck me as rather strange that the symptom of larger files failing, small ones working over a secure connection was reported in "Page loading issues with Firefox 36.0" to which you replied. Non code issues were identified (with links) relating to phasing out of 1024 bit security certificate keys by Mozilla and a known CISCO router configuration issue.

Jaisee please treat this as side comment if issues raised in the post can be discounted as causing or being related to the connection closures you are expeiencing.
User avatar
trolly
Moderator
Posts: 39851
Joined: August 22nd, 2005, 7:25 am

Re: Streaming video url,the remote host closed the connectio

Post by trolly »

Crazy stuff.
I have/had no idea what a) Cisco ACE exists and what it does and b) that you are using it.
As you can see the existence of Cisco ACE is only revealed after my last post.

You see that every little bit of information counts when it comes to network problems.
And sometimes you just fail to put all the pieces together.
Think for yourself. Otherwise you have to believe what other people tell you.
A society based on individualism is an oxymoron. || Freedom is at first the freedom to starve.
Constitution says: One man, one vote. Supreme court says: One dollar, one vote.
jaisee
Posts: 14
Joined: February 12th, 2015, 2:48 am

Re: Streaming video url,the remote host closed the connectio

Post by jaisee »

Hi.

Thanks for your replies.

Can i send the sample asp.net application and you can run that application from your end and see the issue we have faced in firefox latest version. Will it work for you guys? Please confirm.

Note:
This is become very critical for us because lot of our users are using firefox and facing this problem while viewing the 1GB file size video.

waiting for your reply.

Thanks,
JC
User avatar
trolly
Moderator
Posts: 39851
Joined: August 22nd, 2005, 7:25 am

Re: Streaming video url,the remote host closed the connectio

Post by trolly »

Depends on which setup you need.
Please describe as detailed as possible.

I have several systems available but I'm limited in what I can run on them.
Think for yourself. Otherwise you have to believe what other people tell you.
A society based on individualism is an oxymoron. || Freedom is at first the freedom to starve.
Constitution says: One man, one vote. Supreme court says: One dollar, one vote.
User avatar
jscher2000
Posts: 11774
Joined: December 19th, 2004, 12:26 am
Location: Silicon Valley, CA USA
Contact:

Re: Streaming video url,the remote host closed the connectio

Post by jscher2000 »

jaisee wrote:Can i send the sample asp.net application and you can run that application from your end and see the issue we have faced in firefox latest version. Will it work for you guys? Please confirm.

Most people do not run Microsoft IIS servers, and even if we did, might not be able to configure the way you do. Not to mention where to get the equivalent 1gb file...

Does this help: http://stackoverflow.com/questions/2823 ... 0x80070057
Post Reply