Search code examples
.htaccesssymfonygoogle-chromebinaryfiles

Symfony Response net::ERR_CONNECTION_RESET on video file


On my IIS machine (Windows 10) its working, but not on the hosting server (Windows 2008R2, IIS 7.5).

Hosting server: Video is not showing in Chrome by directly opening it via url. I get the error in the console net::ERR_CONNECTION_RESET. But its working in IE. Strangely images are working in Chrome.

This happens since i implemented a security mechanism: A file call is now forced to go through the Framework routing. The route calls a controller, then after some security checks, returns the file as BinaryFileResponse.

I had to adjust the webconfig (htaccess on linux). The video file is under a data/content folder.

<rule name="ID:0001 Folder or File exists" enabled="true" stopProcessing="true">
    <match url="^(?!data/content)[a-z].*$" />
    <conditions logicalGrouping="MatchAny" trackAllCaptures="false">
        <add input="{REQUEST_FILENAME}" matchType="IsFile" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" />
    </conditions>
    <action type="None" />
</rule>
<rule name="ID:0002 Datafolder" enabled="true" stopProcessing="true">
    <match url="^data/((?!content).)*$" />
    <action type="None" />
</rule>

I was searching on the internet and all what i found were possible problems with network, firewall or caching. But i dont think its a problem of that, because its since i am returning the response with Symfony BinaryFileResponse.

$response = new BinaryFileResponse($webPath);
$response->setAutoEtag(true); // Needed for partial loading of video
$response->headers->set('Content-Type', 'video/mp4');
return $response;

Network headers:

General
    Request URL:http://foo.....bar.mp4
    Referrer Policy:no-referrer-when-downgrade
Request Headers
    Provisional headers are shown
    Accept-Encoding:identity;q=1, *;q=0
    chrome-proxy:frfr
    Range:bytes=0-
    Referer:http://foo.....bar.mp4
    User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36

Solution

  • The solution was for IIS 7.5 to return more informations in the response header. Read this.