Unity and SFS2X socket connection problem.

Post here your questions about the Unity / .Net / Mono / Windows 8 / Windows Phone 8 API for SFS2X

Moderators: Lapo, Bax

an12
Posts: 7
Joined: 07 Jul 2011, 09:08

Unity and SFS2X socket connection problem.

Postby an12 » 07 Jul 2011, 09:43

Hello everyone.

Sorry for first message looks like that. I tried to found answer via "Forum search" and google but after 2 weeks struggling still have problem.

I have installed and running SFS2X on Ubuntu 11.04 server.
Access to Admin area is fine. Flash examples after changing local IP to server working fine.

Problem is just with Unity3D examples. I took connection example and made changes to IP and socket and when I run it's giving me
"I/O error: An attempt was made to access a socket in a way forbidden by its access permissions"

I have open 9933 and 8080 sockets on my network firewall and checked access from outside - it is open and have full access.

Also what else I have done it's try different version of client's DLL and examples for Unity.

Still same error.

Working on Windows 7 and as mention earlier admin and Flash examples working fine.

Pleas advise me how to get connected via Unity 3D, any examples or tutorials will be much appreciated.

Thanks.
appels
Posts: 464
Joined: 28 Jul 2010, 02:12
Contact:

Postby appels » 07 Jul 2011, 14:42

are you getting that error in the Unity3d editor or the webplayer ?
an12
Posts: 7
Joined: 07 Jul 2011, 09:08

Postby an12 » 07 Jul 2011, 16:23

I have done few versions. One of version was running on editor in play mode. And also I have made build for web-play and try it as well - result is the same: No connection. I have check ping and ports listening - works fine.
appels
Posts: 464
Joined: 28 Jul 2010, 02:12
Contact:

Postby appels » 07 Jul 2011, 21:30

"I/O error: An attempt was made to access a socket in a way forbidden by its access permissions"


Maybe Thomas or one of the SFS guys can chime in for this error as i don't know if it's the dll that would throw this error or Unity3d.

Also a ping to an SFS server will tell you if it's alive or not but won't access the port. You could do a telnet on the port and you should get some SFS reply.
an12
Posts: 7
Joined: 07 Jul 2011, 09:08

Postby an12 » 08 Jul 2011, 06:01

I have tried telnet from Windows 7 computer - having black screen on terminal and no answer from SFS server about connection status - tried 9933 and 8080 port.

But from other unix computer connection was established ok for both ports. So can it's be Windows 7 problem or client API for Unity3D? This conclusion appeared because flash is working fine.

Does anyone else have that kind problem with SFS2X+Unity3D+remote server installiation?

Thanks.
appels
Posts: 464
Joined: 28 Jul 2010, 02:12
Contact:

Postby appels » 08 Jul 2011, 06:13

Sounds like a local issue on the windows 7 box, i don't think it would be client API.

Have you got the latest update from SFS installed ? RC3 ?
And also the most recent API ?
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 08 Jul 2011, 11:15

That is an OS level error. Most likely firewall or similar blocking your connection

/Thomas
Full Control - maker of Unity/C# and Java SFS API and indie games
Follow on twitter: http://twitter.com/thomas_h_lund
an12
Posts: 7
Joined: 07 Jul 2011, 09:08

Postby an12 » 12 Jul 2011, 10:00

I think I have discover something interesting. I get the connection on the end but it is disappearing in interesting way. I will do some re-checks tonight and post results here.
an12
Posts: 7
Joined: 07 Jul 2011, 09:08

Postby an12 » 12 Jul 2011, 22:27

Here is something interesting going on with SFS2X and unity WebPlay.
I have SFS2X server running under Ubuntu 11.04.
For game development using Windows7 and Unity 3.3
Server and development computer in the same local network. Server has public and local IPs. Standard SFS ports open and listening. Server routed correctly as there also Apache2 running with some other projects.

When I am trying to make simple connection to SFS2X from Unity editor to server - it is working just when build settings set to PC and Mac standalone.

When I changing build settings to WebPlayer - that's it. No connection at all.

I have tried local and public IPs. No connection.

But when I change build settings back to PC and Mac - working again.

What it's could be? Please advise me something.
appels
Posts: 464
Joined: 28 Jul 2010, 02:12
Contact:

Postby appels » 12 Jul 2011, 23:10

yep, you need policy validation in the Unity webplayer to be able to connect to SFS.
You can enable it in SFS webtool or you can use the sockpol.exe that comes with Unity and run that.
You can also do a search for webplayer and policy which will bring up alot of topics on teh subject.
It's a bit like flash policy validation.
you prefetch the policy from SFS before opening the actual connection to the server. Once thats done, you open the socket.
appels
Posts: 464
Joined: 28 Jul 2010, 02:12
Contact:

Postby appels » 12 Jul 2011, 23:15

sample :

Code: Select all

   public void init ()
   {
      if (SmartFoxConnection.IsInitialized) {
         sfClient = SmartFoxConnection.Connection;
      } else {
         if(Application.isWebPlayer || Application.isEditor)
         {
            if(Security.PrefetchSocketPolicy(ServerIp, ServerPort))
            {
               sfClient = new SmartFox (true);
               loginErrorMessage = "auth success...";
            } else {
               loginErrorMessage = "auth failed...";
               return;
            }
         } else {
            sfClient = new SmartFox (true);
         }
      }
....
        sfClient.Connect (ServerIp, ServerPort);
an12
Posts: 7
Joined: 07 Jul 2011, 09:08

Postby an12 » 13 Jul 2011, 09:00

Thank you for the information. I have spent whole night instead good healthy sleep to looking at this problem and really found that I am not alone in this kind situation. Also I have found many people telling what should be done but not too many telling how.

So special thank you for you for clarifying what exactly I should look at.

I was creating stand alone games and demos and was thinking move along to networking will be easy thing... (-:
appels
Posts: 464
Joined: 28 Jul 2010, 02:12
Contact:

Postby appels » 13 Jul 2011, 09:32

Networking can be hard, a push in the right direction makes it easier :)
I don't recall if it's enabled by default in SFS but i think it is.
You can also look for the crossdomain.xml thats in (ApplicationRoot)/SFS2X/config. Thats what SFS sends to Unity upon prefetch.
an12
Posts: 7
Joined: 07 Jul 2011, 09:08

Postby an12 » 13 Jul 2011, 13:41

In my case it's should be kick (not push) ((-:

Yes I have studied already Adobe crossdomain policy spec and checked it on my SFS2X.

One good thing is - it's still a lot to learn!
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 17 Jul 2011, 07:38

Good you solved it. On that particular issue, there is a sticky in this forum - viewtopic.php?t=8878

Too bad you missed it :-/
Full Control - maker of Unity/C# and Java SFS API and indie games

Follow on twitter: http://twitter.com/thomas_h_lund

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 67 guests