Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Unity Starts in Web Browser, but cannot connect to webservice.


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 Dan Violet Sagmiller   Members   -  Reputation: 897

Like
0Likes
Like

Posted 11 March 2013 - 09:37 AM

I have a Unity 3D game.  It connects to a web service, and works great when built as a windows client.  

 

But when I create it as a Web Client, it fails to connect to the web service.

 

I get this message: " Unable to connect to server, please try again later > [url]"

 

The graphics still load and display properly in the web client.

 

The service it is connecting to has the proper cross domain policy file, presumed because the windows client can connect to it.

 

However, in case that is an issue, here is the file:

 

 


<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM
"http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
  <site-control permitted-cross-domain-policies="master-only"/>
  <allow-access-from domain="*"/>
  <allow-http-request-headers-from domain="*" headers="*"/>
</cross-domain-policy>

 

Is there any reason the web client can't connect?

 

(I get the same results when running the web client from the same server as the service)


Moltar - "Do you even know how to use that?"

Space Ghost - “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer."

Dan - "Best Description of AI ever."

My Game(s), Warp Wars is in early development and can be found here: http://blog.WarpWars.Net.


Sponsor:

#2 Kylotan   Moderators   -  Reputation: 3338

Like
0Likes
Like

Posted 11 March 2013 - 10:33 AM

What exactly produces the message you mention? Is that in an exception? Is it in the local log? It doesn't sound like any Unity error I've encountered.

 

You mentioned in your previous post that you're using 'HttpWebClient'. I don't know what this is, exactly. Is this System.Net.WebClient? It may be the case that certain aspects aren't supported. Check here for some function-specific details: http://docs.unity3d.com/Documentation/ScriptReference/MonoCompatibility.html

 

Is there a reason you're not using Unity's WWW class? That may work where a .Net standard class does not.



#3 Dan Violet Sagmiller   Members   -  Reputation: 897

Like
0Likes
Like

Posted 11 March 2013 - 12:41 PM


What exactly produces the message you mention?

 

 

03.11.2013-11.51.png

 

That is a screen shot from where it tells me.  the initial web request is made in a try catch, which caught this error and displayed its message.  There was no inner exception.

 

 

You mentioned in your previous post that you're using 'HttpWebClient'

 

Sorry, I misquoted.  I'm using HttpWebRequest and HttpWebResponse.  According to the list you provided, those work in Web Player.

 

 

Is there a reason you're not using Unity's WWW class?

 

Yes.  WWW cannot be run outside of the main thread.  I tried it, and it throws an error specifically complaining about not being executed from the main thread.  

I have http calls going out to the server quite regularly during game play, and I don't want to lock up the main thread for this data.  


Moltar - "Do you even know how to use that?"

Space Ghost - “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer."

Dan - "Best Description of AI ever."

My Game(s), Warp Wars is in early development and can be found here: http://blog.WarpWars.Net.


#4 Dan Violet Sagmiller   Members   -  Reputation: 897

Like
0Likes
Like

Posted 11 March 2013 - 01:12 PM

BAAAAHHHH!!!! Stupid Documentation.  I've been using HttpWebClient, because I read that it was a functional alternative in Unity.  In the linl you provided, both http classes I'm using (request and response) are in supported in web player.  But the exception I'm getting is System.NotSupportedException.  (sorry for any confusion, I found that there was additional text in my code spitting out additional info on the exception, which gave me the original text.  

 

Do you know if there is any reason to get this exception with a feature Unity says should work?

 

*I'm asking on unity as well.


Edited by Dan Violet Sagmiller, 11 March 2013 - 01:12 PM.

Moltar - "Do you even know how to use that?"

Space Ghost - “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer."

Dan - "Best Description of AI ever."

My Game(s), Warp Wars is in early development and can be found here: http://blog.WarpWars.Net.


#5 Dan Violet Sagmiller   Members   -  Reputation: 897

Like
0Likes
Like

Posted 11 March 2013 - 01:24 PM

ok, so it looks like the unity WWW main thread issue, is that alternate threads cannot directly interact with the GameObjects (or on them)  There is some confusion surrounding this. so I have some experimenting to do.


Moltar - "Do you even know how to use that?"

Space Ghost - “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer."

Dan - "Best Description of AI ever."

My Game(s), Warp Wars is in early development and can be found here: http://blog.WarpWars.Net.


#6 Dan Violet Sagmiller   Members   -  Reputation: 897

Like
0Likes
Like

Posted 13 March 2013 - 05:09 AM

Final resolution:  I got it working.  I used TcpClient and built an Http layer on top of it.  That didn't work either at first, so I did more research and installed a Socket Security Policy Service on my server, and now it runs.  The demo, the service I used and a better description are all posted on my blog, http://warpwars.blogspot.com/

 

Thanks for your help in this!  :)


Moltar - "Do you even know how to use that?"

Space Ghost - “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer."

Dan - "Best Description of AI ever."

My Game(s), Warp Wars is in early development and can be found here: http://blog.WarpWars.Net.


#7 Kylotan   Moderators   -  Reputation: 3338

Like
0Likes
Like

Posted 13 March 2013 - 11:09 AM

Ahh, yes... a lot of the docs are not clear that there are 2 separate ways to notify the client of security settings - the policy file as served up over HTTP (for authorising HTTP access), and a similar file as served directly on a socket (for authorising TCP socket access).






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS