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
0
Question by Torguise100 · Dec 09, 2013 at 12:59 PM · webplayerwww

UriFormatException

I am trying to use WWW to connect and download a text file from a web server however I keep getting this exception:

UriFormatException: Invalid URI: The format of the URI could not be determined. MonoForks.System.Uri..ctor (System.String uriString, Boolean dontEscape) MonoForks.System.Uri..ctor (System.String uriString) (wrapper remoting-invoke-with-check) MonoForks.System.Uri:.ctor (string) MonoForks.System.Windows.Interop.PluginHost.get_SourceUri () MonoForks.System.Windows.Browser.Net.CrossDomainPolicyManager.GetCachedWebPolicy MonoForks.System.Uri uri) UnityEngine.UnityCrossDomainHelper.GetSecurityPolicy (System.String requesturi_string, IPolicyProvider policyProvider) UnityEngine.UnityCrossDomainHelper.GetSecurityPolicy (System.String requesturi_string)

This only happens in any form of WebPlayer platform both inside and outside the editor however works perfectly fine when used in a standalone or IOS build. Following is the line that creates a new WWW request (dummy used for security).

WWW faqFile = new WWW("http://127.127.127.127/faq_text.txt?p=" + (int)(Time.time * 1000));

Where the value on the end is to make sure it returns a new version of the file each time not a cached version, and the dummy ip replaces the original ip.

When the original URL is entered in a web browser I am able to access the file. There is no issues with permissions and no problems with crossdomain.xml. This is all simply to do with the URI being used as far as I can tell.

Could anyone please shed some light on this issue?

Thanks

EDIT The issue appears to be with the editor emulation of the webplayer. The webplayer appears to be accessing the data fine now. Is there any work-arounds for the editor? It's kind of a pain to make a new build to test every change.

Thanks for all responses

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
0

Answer by Bunny83 · Dec 09, 2013 at 01:15 PM

First: From what place do you run your webplayer? Do you have it on your actual server and load the player via it's appropriate URL? If not the webplayer is required to check the crossdomain policy file on the server you try to contact.

Another thing is, we have no idea how your URL looks like. A common mistake is to try to add basic authorization information at the front of the URL (with @) but this is not supported by the http. Most browsers interpret this information and add an "Authorization" header to the request.

See this post for how you can add such an header:
http://forum.unity3d.com/threads/148521-Unity-WWW-and-htaccess

There might be something else wrong with your URL, however you stripped the most important part. Can you replace all elements you have in there with dummys and explaind each part?

Otherwise this leads nowhere...

Comment
Add comment · Show 9 · 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 Torguise100 · Dec 09, 2013 at 02:20 PM 0
Share

I am running my WebPlayer from my development machine both in firefox and chrome browsers and from the unity editor WebPlayer emulation. I have a crossdomain policy file that should allow access from any domain.

The missing section is to hide the ip address that is being used as to let this out would be a security risk. The server that I am trying to access data from is on a separate network to my machine and so separate to the location of my WebPlayer.

The blank space it just the ip address of the server, the question has been updated to explain it a little better

avatar image Bunny83 · Dec 09, 2013 at 03:37 PM 0
Share

Well, if it's just an IPv4 address, i have no idea what's wrong here. If it's an IPv6 address keep in $$anonymous$$d the URL format.

Just to be clear: The exception is thrown by the URI constructor, so your URI string has to be invalid. $$anonymous$$aybe some non-printable characters like "newline", "linefeed", ...

Try storing the request url in a string variable and do this Debug.Logs:

     Debug.Log("URL: >" + yourURLstring + "<");
     Debug.Log("URL length: " + yourURLstring.Length);

Check the debug log for line breaks or spaces.

Are you 100% sure that's how your url looks like? I can fully understand that you don't want to post your real IP / hostname / exact path / exactfilenames since that's all a potintial security risk. I just asked for a 1:1 replacement.

     http://my.DomainName.com:3345/somesecret/path/importantFile.txt

A 1:1 replacement would be:

     http://some.DomainName:somePortNumber/PathA/PathB/somefile.txt

It's difficult to help you with a malformed URI when we don't see the URI ;)

avatar image Torguise100 · Dec 09, 2013 at 03:45 PM 0
Share

I have updated the format of the ip to show more correctly how it looks, however this might be redundant now since it has begun working in the webplayer builds It appears now to be an editor emulation problem now since it only fails in the editor.

Thanks for your help and quick responses :)

avatar image Bunny83 · Dec 09, 2013 at 04:00 PM 0
Share

ps: i just visited my project graveyard and revived my old UA test project ;)

I've created this script:

 public class TestURI : $$anonymous$$onoBehaviour
 {
     string log = "";
     IEnumerator Start()
     {
         string url = "http://127.0.0.1/php/somefile.php?p=" + (int)(Time.time*1000 + Random.Range(0.0f,200.0f));
         WWW w = new WWW(url);
         yield return w;
         log += w.text + "\r\n";
     }
     
     void OnGUI()
     {
         GUILayout.Label(log);
     }
 }

build a webplayer, started my xitami and loaded the webplayer file directly in my firefox. As result i see the output of my php file in the webplayer.

So i can't reproduce your problem. There has to be something wrong with your URI. You definately have just an iPv4 address as hostname? no custom port, no userinformation?

avatar image Torguise100 · Dec 09, 2013 at 04:06 PM 0
Share

There is definitely no ports or user information required to access any of this data, it is being accessed using the exact same uri on IOS and standalone builds and it works perfectly fine in both editor and build.

It is just the editor emulation that is not working with it now.

Show more comments

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

17 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Is WWW class usable in Android platform? 1 Answer

WWW Request runs in Editor but not in Webplayer 1 Answer

Why can't I build Web Player in Unity while I have no problems with building standalone versions? 2 Answers

Is HttpWebRequest supposed to work in Web Builds or not? 1 Answer

How To Use LoadUnityWeb To Load a New Webplayer 2 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