Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by StarFluke · Jun 28, 2014 at 04:32 PM · errorwebplayerserversidenodejsinvalid

I have .unity3d web on a Node.js server but the Unity3d app will not load. I believe it is a mime type restriction. Is there a Node.js function or plugin that can set up my mime types?

I cannot play my unity3d game files (mime type="application/vnd.unity") over a Node.js connection. (I am able to play the unity3d through the Apache Vhosts Access.) I just started a new instance of a Node.js app server to begin development of server side game components.

I have a basic server.js:

 var http = require('http'),
     fs = require('fs');
 
 
 fs.readFile("./unityBase.html", function (err, html) {
     if (err) {
         throw err; 
     }       
     http.createServer(function(request, response) {  
         response.writeHead(200, {"Content-Type": "text/html"});  
         response.write(html);  
         response.end();  
     }).listen(8080);
 });

And a simple unityBase.html:

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
     <head>
         <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
         <title>Unity Web Player | StarFluke</title>
     </head>
     
     <body>
         <div id="unityPlayer"><embed src="build.unity3d" type="application/vnd.unity" width="960" height="600" firstframecallback="UnityObject2.instances[0].firstFrameCallback();" enabledebugging="0" style="display: block; width: 960px; height: 600px;">
         </div>
 </body>

(I stripped out a Style block for you to see the code easier.)

As I mentioned earlier, the unityBase.html runs fine in Apache Vhost Access; it does not run through a normal browser connection to www.starfluke.com or starfluke.com. It gives an error that claims the unity3d file is corrupt.

Do you have any suggestions of what I might try? Anything would be helpful, I am new at Node.js.

Oh, when testing the page make sure you have the Unity3D web player installed: (http://unity3d.com/webplayer). I stripped out that part of the page code to try to narrow down the problem.

Thank you, Daniel

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by StarFluke · Jul 02, 2014 at 06:59 AM

Solution! It was not a normal mime type problem. Node.JS needed to know the type of the unity3d file before serving it so the brute force and naive file read done in the server.js above was never going to work.

Using Node.js Express (or a number of other HTML server modules) is the quickest solution unless you really are tight on performance.

I am programming in Eclipse with NodeClipse and chose to go with a set of modules already supported by this plugin (e.g. {Express, ejs, LESS} one of nine supported combinations.) This is a great combo to host a Unity3D game on!

Daniel Game Daddy

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image thomasbaldwinj · Sep 11, 2014 at 06:42 PM 1
Share

Can you explain your answer in a little more detail please? I'm having a similar issue, it's saying the download failed. I've put my WebPlayer.html file and WebPlayer.unity3d file in a public directory so they're treated as static files and added this code to my app.js file:

 app.use('/public', express.static(__dirname + '/public'));
 express.static.mime.define({
   'application/vnd.unity': ['unity3d'],
 });

But I still cannot get it to work

Here's the link to my question: http://answers.unity3d.com/questions/788552/nodejs-with-unity.html

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Error running WebGL on any browser 0 Answers

Web Player crashes (Invalid unity web file (decompression failure)) 1 Answer

What kind of error handling does the WWW class have? 1 Answer

What is an alternative to using System.IO Stream when building for webplayer ? 3 Answers

What "Invalid OpenGL Context for rendering" means? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges