No exception/event for failed connection?

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

Moderators: Lapo, Bax

Post Reply
Micr0mega
Posts: 7
Joined: 23 Aug 2012, 15:23

No exception/event for failed connection?

Post by Micr0mega »

Good day,

Recently I have started a Unity3D project and utilize SmartFoxServer 2X as our server of choice.

I have set up a basic chat client, to test the robustness of Unity and SFS2X. Overall this looks quite good, but I am having some difficulties with the way the SFS2X client library seems to handle connections.

When specifying a non-existing hostname or IP address, or a host that is not running the SFS2X server, there does not seem to be any event or exception that indicates this as an error. Now I do see a message indicating this in the debug log:

Code: Select all

[SFS - ERROR] TCPSocketLayer: Connection error: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
  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.Socket.Connect (System.Net.IPAddress address, Int32 port) [0x00000] in <filename unknown>:0 
  at Sfs2X.Core.Sockets.TCPSocketLayer.ConnectThread () [0x00000] in <filename unknown>:0 
but there is no exceptions which I will be able to catch. A triggered event would also be a good option, as indicated on the AS3 forums. However, the OnConnection event does not fire with the above error from the debug logs (at least, not in the C# library). I have seen this in both my own client and the Connector demo client.
Please don't make me parse the debug logs :roll:

Currently I am using Unity 3.5.3f3 and your C# client library version 1.0.2, but I have also observed the same behavior in client version 1.0.1.

I am also experiencing this issue: http://forums.smartfoxserver.com/viewto ... 20&t=14548
Is there any news on the pending fix? It is quite an nuisance.

Thanks in advance for replying :)
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: No exception/event for failed connection?

Post by Lapo »

Hi,
as regards the first problem it sounds strange, I've just launched one of our examples with no server running and the login screen shows the connection failure, so the event is handled correctly.
Can you compare your code with ours? Maybe there's something in there.

As regards the 2nd issue I'll leave it to Thomas, as he's the expert here :)
Lapo
--
gotoAndPlay()
...addicted to flash games
Micr0mega
Posts: 7
Joined: 23 Aug 2012, 15:23

Re: No exception/event for failed connection?

Post by Micr0mega »

Hi Lapo,

Thanks for replying. I did another comparison of my code with the connector example, and indeed, there was something wrong there:
I put the ProcessEvents method inside an IsConnected check :lol: So processing would not occur when not connected, causing the event not to fire.
So that's solved!

Lets hope Thomas can shine some light on the second issue :)
I'll reply in the original thread, as I might have a bit more information for him to work with.
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: No exception/event for failed connection?

Post by Lapo »

I know he was off to a conference, but I think he should be back during the week.
Glad you solved the first problem. Stay tuned :)
Lapo
--
gotoAndPlay()
...addicted to flash games
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Re: No exception/event for failed connection?

Post by ThomasLund »

It should be fixed in 1.0.3 version of the API. But also make sure you update your server to latest version.

Several good fixes are in the new server

/Thomas
Full Control - maker of Unity/C# and Java SFS API and indie games
Follow on twitter: http://twitter.com/thomas_h_lund
Post Reply