• Advertisement
Sign in to follow this  

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

This topic is 1774 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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)

Share this post


Link to post
Share on other sites
Advertisement

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.

Share this post


Link to post
Share on other sites


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.  

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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!  :)

Share this post


Link to post
Share on other sites

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).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
  • Advertisement
  • Popular Now

  • Advertisement
  • Similar Content

    • By eldwin11929
      We're looking for programmers for our project.
      Our project is being made in Unity
      Requirements:
      -Skills in Unity
      -C#
      -Javascript
      -Node.js
      We're looking for programmers who can perform a variety of functions on our project.
      Project is a top-down hack-and-slash pvp dungeon-crawler like game. Game is entirely multiplayer based, using randomized dungeons, and a unique combat system with emphasis on gameplay.
      We have a GDD to work off of, and a Lead Programmer you would work under.
      Assignments may include:
      -Creating new scripts of varying degrees specific to the project (mostly server-side, but sometimes client-side)
      -Assembling already created monsters/characters with existing or non-existing code.
      -Creating VFX
      -Assembling already created environment models
      If interested, please contact: eldwin11929@yahoo.com
      This project is unpaid, but with royalties.
       
      ---
      Additional Project Info:
      Summary:
      Bassetune Reapers is a Player-verus-Player, competitive dungeon crawler. This basically takes on aspects of dungeon crawling, but with a more aggressive setting. Players will have the option to play as the "dungeon-crawlers" (called the 'Knights', or "Knight Class", in-game) or as the "dungeon" itself (literally called the 'Bosses', or "Boss Class", in-game). What this means is that players can choose to play as the people invading the dungeon, or as the dungeon-holders themselves.
      Key Features:
      -Intense, fast-paced combat
      -Multiple skills, weapons, and ways to play the game
      -Tons of different Bosses, Minibosses, creatures and traps to utilize throughout the dungeon
      -Multiple unique environments
      -Interesting, detailed lore behind both the game and world
      -Intricate RPG system
      -Ladder and ranking system
      -Lots of customization for both classes s of customization for both classes
    • By RoKabium Games
      Custom coffee mugs have arrived... More caffeine!
      Have a great weekend everyone! 
      #gamedev #indiedev #sama #caffeine
    • By Atwo Studios
       
      Hey guys,

      Anthony here from Atwo Studios bringing you some new updates for the new year!
      In this video I go over our game ROY, the new games and some general updates to the company!

      If you have not checked out ROY feel free to give it a try! Many people have said they enjoyed the game thus far!
      ROY: https://goo.gl/o6JJ5P
       
    • By Affgoo
      https://play.google.com/store/apps/details?id=com.NE.Alien
      still a lot of work to do, but its pretty stable  please let me know what you think <3
      Atlas Sentry is a game of destroy everything. Using your turret, simply swivel and shoot your way to victory, upgrading your weapons to unleash destruction on the variety of spaceships. The bigger your combo’s the more score you get! Earn silver as you play and then purchase new weapons and abilities to better deal with your enemy. Different enemies use different tactics and weapons, work out your own priorities in their destruction order. 

      Features: 
      **2 different game modes 
      **A level select mode with 20 difficult levels including a final boss, can you defeat it? **Arcade mode of endless destruction, how long will you last? 
      **High scores to compete against others, see who can take the top spot. 
       
    • By Chamferbox
      Chamferbox, a mini game asset store has just opened with some nice game assets, 
      Here you can find a free greek statue asset 

      Also check their dragon, zombie dragon and scorpion monster out:



      They're running the Grand Opening Sale, it's 30% off for all items, but for gamedev member, you can use this coupon code:
      GRANDOPEN
      to get 50% off prices What are you waiting for, go to
      http://chamferbox.com
      and get those models now!

      View full story
  • Advertisement