Search Unity

WebGL incorrect header check bug again in latest Beta?

Discussion in 'Web' started by ivank, Jun 17, 2016.

  1. ivank

    ivank

    Joined:
    Nov 16, 2013
    Posts:
    105
    Hello,
    I use the Unity 5 beta 21 (the most current at the time of writing) for publishing the WebGL content.
    Even after repeated attempts I get the "famous" error "Uncaught incorrect header check".
    Tried on IE 11 and Chrome 51.

    The same happened with the previous beta 20 (haven't tried before that).
    As this bug was claimed to be resolved long ago, is it possible it has been reintroduced again?

    The WebGL content itself is very simple - just few textured objects... the link is:
    http://www.spg.cz/ivan/xpokus/glpotvor/

    If the content is run from a local host (it means "Build & Run" in Build settings), it shows up ok; if the published files are then uploaded and viewed from the server, the error message "Uncaught..." appears.

    Any ideas?

    Ivan K.
     
  2. alexsuvorov

    alexsuvorov

    Unity Technologies

    Joined:
    Nov 15, 2015
    Posts:
    327
    Hello ivank.

    Your problem has nothing to do with WebGL or Unity in general. The .data and .mem files are not served from your server. This is a common issue for people who start using IIS, as it does not serve files without associated handlers by default (unlike, for example, Apache). To resolve this, add the application/octet-stream MIME-Type for .data .mem .unity3d .datagz .memgz .jsgz .unity3dgz file extensions.

    You can do this using IIS Manager, or just put the following web.config file into your game folder on the server:
    Code (config):
    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <configuration>
    3.     <system.webServer>
    4.         <staticContent>
    5.             <mimeMap fileExtension=".mem" mimeType="application/octet-stream" />
    6.             <mimeMap fileExtension=".data" mimeType="application/octet-stream" />
    7.             <mimeMap fileExtension=".unity3d" mimeType="application/octet-stream" />
    8.             <mimeMap fileExtension=".memgz" mimeType="application/octet-stream" />
    9.             <mimeMap fileExtension=".datagz" mimeType="application/octet-stream" />
    10.             <mimeMap fileExtension=".unity3dgz" mimeType="application/octet-stream" />
    11.             <mimeMap fileExtension=".jsgz" mimeType="application/octet-stream" />
    12.         </staticContent>
    13.     </system.webServer>
    14. </configuration>
    15.  
    To check whether your server is configured correctly, try accessing http://www.spg.cz/ivan/xpokus/glpotvor/Development/UNI BUILD unstrip Potvor.mem from your browser.
     
    Last edited: Jun 17, 2016
    Quarty and ivank like this.
  3. ivank

    ivank

    Joined:
    Nov 16, 2013
    Posts:
    105
    Hello Alex,
    thanks for the quick reaction and valuable advice - now it works, exactly as you described!

    Maybe it would be useful to even put a small note into the Manual so users would not bug you again in the future - something like "...if you see the message ´Uncaught incorrect header...´, do not get scared and just adjust the mime-type..."

    Thanks again
     
  4. alexsuvorov

    alexsuvorov

    Unity Technologies

    Joined:
    Nov 15, 2015
    Posts:
    327
    Yes, this will be added to the manual a bit later.

    By the way, for release builds you may also use an extended server configuration, that can improve the loading time by serving compressed content with properly adjusted headers. This way decompression will be performed natively by the browser, which is a bit faster.

    In order to achieve this, first make sure you have URL Rewrite module installed (if not, you can get it here http://www.iis.net/downloads/microsoft/url-rewrite), then use the following web.config inside your Release subfolder:
    Code (config):
    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <configuration>
    3.     <system.webServer>
    4.         <staticContent>
    5.             <mimeMap fileExtension=".mem" mimeType="application/octet-stream" />
    6.             <mimeMap fileExtension=".data" mimeType="application/octet-stream" />
    7.             <mimeMap fileExtension=".unity3d" mimeType="application/octet-stream" />
    8.             <mimeMap fileExtension=".memgz" mimeType="application/octet-stream" />
    9.             <mimeMap fileExtension=".datagz" mimeType="application/octet-stream" />
    10.             <mimeMap fileExtension=".unity3dgz" mimeType="application/octet-stream" />
    11.             <mimeMap fileExtension=".jsgz" mimeType="application/octet-stream" />
    12.         </staticContent>
    13.         <rewrite>
    14.             <rules>
    15.                 <rule name="Append gz suffix to WebGL content requests">
    16.                     <match url="(.*)\.(js|data|mem|unity3d)$" />
    17.                     <conditions>
    18.                         <add input="{HTTP_ACCEPT_ENCODING}" pattern="gzip" />
    19.                         <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
    20.                     </conditions>
    21.                     <action type="Rewrite" url="{R:1}.{R:2}gz" />
    22.                 </rule>
    23.             </rules>
    24.             <outboundRules>
    25.                 <rule name="Append gzip Content-Encoding header to rewritten responses">
    26.                     <match serverVariable="RESPONSE_Content-Encoding" pattern=".*" />
    27.                     <conditions>
    28.                         <add input="{REQUEST_FILENAME}" pattern="\.(js|data|mem|unity3d)gz$" />
    29.                     </conditions>
    30.                     <action type="Rewrite" value="gzip" />
    31.                 </rule>
    32.             </outboundRules>
    33.         </rewrite>
    34.     </system.webServer>
    35. </configuration>
     
    Last edited: Jun 22, 2016
  5. ankitlinuxbean

    ankitlinuxbean

    Joined:
    Feb 21, 2017
    Posts:
    7
  6. roka

    roka

    Joined:
    Sep 12, 2010
    Posts:
    598

    Code (CSharp):
    1.   var Module = {
    2.     TOTAL_MEMORY: 268435456,
    3.     errorhandler: null,            // arguments: err, url, line. This function must return 'true' if the error is handled, otherwise 'false'
    4.     compatibilitycheck: null,
    5.     dataUrl: "Release/.data",
    6.     codeUrl: "Release/.js",
    7.     memUrl: "Release/.mem",
    8.    
    9.   };
    10.  
    The file name is not present .....
     
  7. ankitlinuxbean

    ankitlinuxbean

    Joined:
    Feb 21, 2017
    Posts:
    7
    New issue : UnityLoader.js 404 not found. But i have that file.
     
  8. ankitlinuxbean

    ankitlinuxbean

    Joined:
    Feb 21, 2017
    Posts:
    7
    My web.config

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
    <system.webServer>
    <rewrite>
    <rules>
    <rule name="Imported Rule 2" enabled="true" stopProcessing="true">
    <match url="(.*)Release(.*)\.data" ignoreCase="true" />
    <action type="Rewrite" url="{R:1}Compressed{R:2}.datagz" />
    <conditions>
    </conditions>
    </rule>
    <rule name="Imported Rule 1" enabled="true" stopProcessing="true">
    <match url="(.*)Release(.*)\.js" ignoreCase="true" />
    <conditions logicalGrouping="MatchAll">
    <add input="{HTTP_ACCEPT_ENCODING}" pattern="gzip" ignoreCase="true" />
    </conditions>
    <action type="Rewrite" url="{R:1}Compressed{R:2}.jsgz" />
    </rule>
    <rule name="Imported Rule 3" enabled="true" stopProcessing="true">
    <match url="(.*)Release(.*)\.mem" ignoreCase="true" />
    <action type="Rewrite" url="{R:1}Compressed{R:2}.memgz" />
    <conditions>
    </conditions>
    </rule>
    <rule name="Imported Rule 4" enabled="true" stopProcessing="true">
    <match url="(.*)Release(.*)\.unity3d" ignoreCase="true" />
    <action type="Rewrite" url="{R:1}Compressed{R:2}.unity3dgz" />
    <conditions>
    </conditions>
    </rule>
    </rules>
    <outboundRules>
    <rule name="Rewrite JSGZ header" preCondition="IsJSGZ" stopProcessing="false">
    <match serverVariable="RESPONSE_Content_Encoding" pattern=".*" />
    <action type="Rewrite" value="gzip" />
    </rule>
    <rule name="Rewrite MemGZ header" preCondition="IsMemGZ" stopProcessing="false">
    <match serverVariable="RESPONSE_Content_Encoding" pattern=".*" />
    <action type="Rewrite" value="gzip" />
    </rule>
    <rule name="Rewrite DataGZ header" preCondition="IsDataGZ" stopProcessing="false">
    <match serverVariable="RESPONSE_Content_Encoding" pattern=".*" />
    <action type="Rewrite" value="gzip" />
    </rule>
    <rule name="Rewrite Unity3DGZ header" preCondition="IsUnity3DGZ" stopProcessing="true">
    <match serverVariable="RESPONSE_Content_Encoding" pattern=".*" />
    <action type="Rewrite" value="gzip" />
    </rule>
    <preConditions>
    <preCondition name="IsJSGZ">
    <add input="{PATH_INFO}" pattern="\.jsgz$" />
    </preCondition>
    <preCondition name="IsMemGZ">
    <add input="{PATH_INFO}" pattern="\.memgz$" />
    </preCondition>
    <preCondition name="IsDataGZ">
    <add input="{PATH_INFO}" pattern="\.datagz$" />
    </preCondition>
    <preCondition name="IsUnity3DGZ">
    <add input="{PATH_INFO}" pattern="\.unity3dgz$" />
    </preCondition>
    </preConditions>
    </outboundRules>
    </rewrite>
    <staticContent>
    <remove fileExtension=".unity3d" />
    <mimeMap fileExtension=".unity3d" mimeType="application/vnd.unity" />
    <mimeMap fileExtension=".mem" mimeType="application/octet-stream" />
    <mimeMap fileExtension=".data" mimeType="application/octet-stream" />
    <mimeMap fileExtension=".memgz" mimeType="application/octet-stream" />
    <mimeMap fileExtension=".datagz" mimeType="application/octet-stream" />
    <mimeMap fileExtension=".unity3dgz" mimeType="application/octet-stream" />
    <mimeMap fileExtension=".jsgz" mimeType="application/x-javascript; charset=UTF-8" />
    </staticContent>
    <urlCompression doStaticCompression="true" doDynamicCompression="false" />
    </system.webServer>
    </configuration>
     
  9. ankitlinuxbean

    ankitlinuxbean

    Joined:
    Feb 21, 2017
    Posts:
    7
    Hello @roka ,alex
    I have removed above web.config and used the config file as seen below
    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <configuration>
    3. <system.webServer>
    4. <staticContent>
    5. <mimeMap fileExtension=".mem" mimeType="application/octet-stream" />
    6. <mimeMap fileExtension=".data" mimeType="application/octet-stream" />
    7. <mimeMap fileExtension=".unity3d" mimeType="application/octet-stream" />
    8. <mimeMap fileExtension=".memgz" mimeType="application/octet-stream" />
    9. <mimeMap fileExtension=".datagz" mimeType="application/octet-stream" />
    10. <mimeMap fileExtension=".unity3dgz" mimeType="application/octet-stream" />
    11. <mimeMap fileExtension=".jsgz" mimeType="application/octet-stream" />
    12. </staticContent>
    13. <rewrite>
    14. <rules>
    15. <rule name="Append gz suffix to WebGL content requests">
    16. <match url="(.*)\.(js|data|mem|unity3d)$" />
    17. <conditions>
    18. <add input="{HTTP_ACCEPT_ENCODING}" pattern="gzip" />
    19. <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
    20. </conditions>
    21. <action type="Rewrite" url="{R:1}.{R:2}gz" />
    22. </rule>
    23. </rules>
    24. <outboundRules>
    25. <rule name="Append gzip Content-Encoding header to rewritten responses">
    26. <match serverVariable="RESPONSE_Content-Encoding" pattern=".*" />
    27. <conditions>
    28. <add input="{REQUEST_FILENAME}" pattern="\.(js|data|mem|unity3d)gz$" />
    29. </conditions>
    30. <action type="Rewrite" value="gzip" />
    31. </rule>
    32. </outboundRules>
    33. </rewrite>
    34. </system.webServer>
    35. </configuration>
    Now i have 500m internal server error. Can you please help me on this. Please suggest me ASAP.
     
  10. aaronfranke

    aaronfranke

    Joined:
    Jan 23, 2017
    Posts:
    20
    This is a common issue for people who start using IIS, as it does not serve files without associated handlers by default (unlike, for example, Apache).​

    However, I'm getting this issue on Apache/2.4.18 (Ubuntu) and I don't know what I'm supposed to do.
     
  11. alexsuvorov

    alexsuvorov

    Unity Technologies

    Joined:
    Nov 15, 2015
    Posts:
    327
    Hello ankitlinuxbean.

    Make sure you have URL Rewrite module installed (if not, you can get it here http://www.iis.net/downloads/microsoft/url-rewrite).
    Assuming that you are using Unity version below 5.6, try to use the following web.config (just to check if it works):
    Code (config):
    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <configuration>
    3.     <system.webServer>
    4.         <staticContent>
    5.             <remove fileExtension=".mem" />
    6.             <remove fileExtension=".data" />
    7.             <remove fileExtension=".unity3d" />
    8.             <remove fileExtension=".jsbr" />
    9.             <remove fileExtension=".membr" />
    10.             <remove fileExtension=".databr" />
    11.             <remove fileExtension=".unity3dbr" />
    12.             <remove fileExtension=".jsgz" />
    13.             <remove fileExtension=".memgz" />
    14.             <remove fileExtension=".datagz" />
    15.             <remove fileExtension=".unity3dgz" />
    16.             <mimeMap fileExtension=".mem" mimeType="application/octet-stream" />
    17.             <mimeMap fileExtension=".data" mimeType="application/octet-stream" />
    18.             <mimeMap fileExtension=".unity3d" mimeType="application/octet-stream" />
    19.             <mimeMap fileExtension=".jsbr" mimeType="application/octet-stream" />
    20.             <mimeMap fileExtension=".membr" mimeType="application/octet-stream" />
    21.             <mimeMap fileExtension=".databr" mimeType="application/octet-stream" />
    22.             <mimeMap fileExtension=".unity3dbr" mimeType="application/octet-stream" />
    23.             <mimeMap fileExtension=".jsgz" mimeType="application/octet-stream" />
    24.             <mimeMap fileExtension=".memgz" mimeType="application/octet-stream" />
    25.             <mimeMap fileExtension=".datagz" mimeType="application/octet-stream" />
    26.             <mimeMap fileExtension=".unity3dgz" mimeType="application/octet-stream" />
    27.         </staticContent>
    28.     </system.webServer>
    29. </configuration>
    And if possible, share a working link to your build (you may share it privately).


    Hello aaronfranke.
    Provide more detailed information about your issue and share a link if possible.