• 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
Question by Murdock · May 30, 2013 at 02:01 PM · facebooksockethttpcrossdomain

Uniweb(sockets) + Facebook

Hi, I'm trying to connect to Facebook Graph API using UniWeb plugin. Everything works fine on iOS, but on the web player I'm getting this exception:

 System.Security.SecurityException: Unable to connect, as no valid crossdomain policy was found
   at System.Net.Sockets.Socket.Connect_internal (IntPtr sock, System.Net.SocketAddress sa, System.Int32& error, Boolean requireSocketPolicyFile) [0x00000] in <filename unknown>:0 
   at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP, Boolean requireSocketPolicy) [0x00000] in <filename unknown>:0 
   at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP) [0x00000] in <filename unknown>:0 
   at System.Net.Sockets.TcpClient.Connect (System.Net.IPEndPoint remote_end_point) [0x00000] in <filename unknown>:0 
   at System.Net.Sockets.TcpClient.Connect (System.Net.IPAddress[] ipAddresses, Int32 port) [0x00000] in <filename unknown>:0 

The same example works ok if I connect using WWW instead of UniWeb.

This is the relevant code:

 // This works ok    
  IEnumerator  GetUserInfoWWW()
 {
     WWW www = new WWW("https://graph.facebook.com/100002347686605?fields=id,name,friends&access_token=" + accessToken);
         
     yield return www;
         
     response = www.text;
     error = www.error;
         
 }
     
 // This doesn't work. I get System.Security.SecurityException: Unable to connect, as no valid crossdomain...
 IEnumerator  GetUserInfoUniWeb()
 {
     var request = new HTTP.Request("GET", "https://graph.facebook.com/100002347686605?fields=id,name,friends&access_token=" + accessToken);
 
     request.Send();
         
     while(!request.isDone) yield return new WaitForEndOfFrame();
         
     if(request.exception != null) 
     {
             Debug.LogError(request.exception);
     }
     else
     {
             var response = request.response;
             Debug.Log(response.status);
         Debug.Log(response.GetHeader("Content-Type"));
         Debug.Log(response.Text);
     }
 }

I am missing something? UniWeb uses sockets to implement the http client, I don't know if this is relevant to this situation.

The UniWeb documentation says something about calling PrefetchSocketPolicy in order to the examples to work on the web player. I'm calling it like this:

 Security.PrefetchSocketPolicy("https://graph.facebook.com", 843);

But it doesn't makes any difference.

I will appreciate any help. Thanks!

Comment

People who like this

0 Show 3
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 Graham-Dunnett ♦♦ · May 30, 2013 at 03:50 PM 0
Share

Does Facebook support a socket policy file on port 843 on graph.facebook.com?

avatar image Murdock · May 30, 2013 at 04:04 PM 0
Share

Hmm, I just ran a test and it seems it doesn't:

This is what I get against graph.facebook.com:

 iMac:~ murdock$ telnet graph.facebook.com 843
 Trying 31.13.85.16...
 Connected to star.c10r.facebook.com.
 Escape character is '^]'.
 <policy-file-request/>
 Connection closed by foreign host.

And this is when I connect to my own server (which is running the socket policy server provided with Unity):

 iMac:~ murdock$ telnet 172.16.48.128 843
 Trying 172.16.48.128...
 Connected to cgwks419.comp.local.
 Escape character is '^]'.
 <policy-file-request/>
 <?xml version="1.0"?>
 <cross-domain-policy>
    <allow-access-from domain="*" to-ports="1200-1220"/> 
 </cross-domain-policy>"Connection closed by foreign host.

This means that I can't connect to graph API using UniWeb plugin? I'm lost, I have very little experience with servers.

avatar image Graham-Dunnett ♦♦ · May 30, 2013 at 09:03 PM 0
Share

Not sure. If Uniweb uses sockets, then in a webplayer it'll trigger the fetch of the socket policy file. If Facebook doesn't have one, then the security policy will stop you using sockets.

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

14 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

Related Questions

Facebook, Webplayer and the crossdomain policy 1 Answer

Problems with WWW calls in Facebook canvas game in Unity5 0 Answers

WebPlayer posting to Facebook 0 Answers

Yet another socket-and-crossdomain-policy question 1 Answer

socket and crossdomain problem (Security.PrefetchSocketPolicy ) 1 Answer


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