Anyone have UDP issues on Windows?

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

Moderators: Lapo, Bax

ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 29 Nov 2010, 07:43

OK - sounds like you all are on Windows. Will need to dust off a copy and give it some love there.

Thanks! Watch out for a new test soon

Anyone on Mac that can confirm the non-crash there? (Still havent had a single issue yet there).

Oh - UDP should have no connection to policy files at all. Running against my local SFS server with a 3.0 webplayer it also works fine.

/Thomas
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 30 Nov 2010, 20:15

OK - found the problem and fixed it. Crossing fingers. Confirmed by a few people already, but would like to get more eyes on it before declaring it fixed fixed and ready for release.

So give this a test please!!

http://www.fullcontrol.dk/downloads/SFS ... 101130.dll

Also has a small fix for room.ContainsVariable() which would throw an exception instead of returning false when variable not found.

/Thomas
stevets
Posts: 60
Joined: 11 Jul 2010, 12:22
Location: USA

Postby stevets » 30 Nov 2010, 21:41

I tested the SmartFox2-20101130.dll using Unity3.1f4 (windows version)
It appears to work now without crashing the editor.
What fixed the problem Thomas? Just curious.

Thanks Steve
tpenn
Posts: 95
Joined: 03 Aug 2010, 18:48

Postby tpenn » 30 Nov 2010, 23:52

Tested, and my results were less successful.

My first attempt, I had forgotten to add the socket addresses for UDP in the Server Configurator, and so naturally UDP failed to initialize (the UDP_INIT event had success = false). No attempts to send via UDP were made. However, shutting down Unity triggered this exception: "SocketException: A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied." Attempting to run the game again after receiving this exception would lock up Unity, every time.

So I fixed my goof, and initted UDP successfully. ~10 seconds after the UDP_INIT event was received (with success = true), I received another UDP_INIT, this time with success = false. However, it did appear that sending and receiving via UDP was working fine.

However, after running my game for a brief time (which admittedly generates a quite a bit of traffic), the server became unresponsive, and my clients received no UDP or TCP responses, reminiscent to an issue that was fixed with RC-1a.

The good news is no exception on shutdown when I initted successfully, and no crash.
GRIM2594
Posts: 52
Joined: 07 Nov 2010, 23:16

Postby GRIM2594 » 01 Dec 2010, 01:32

I don't want to speak too soon, but it does appear to be fixed! I haven't crashed yet, while using UDP on Windows.
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 01 Dec 2010, 05:48

Ohhh!!! Sounds like the issue was mostly nailed then!

1)
First - on all the exception messages - many of these are debug mesages. If they say "SFS DEBUG" or similar before the exception message, then the exceptions are caught and not thrown! Some of these exception messages happen on normal shutdown when the socket is closed. That throws some kind of exception inside the API - and I show it at the moment.

If there is NO "SFS DEBUG" or similar in front, then its a real exception.

Its not very end user friendly and can lead to much confusion. So I will remove these messages in the next real release.

2)
So what was wrong!

3 things - first off, the API used some threads inside to read data from the sockets. On shutdown we called Abort() on them - that turns out to be a source of crashes. Reworked that, so that threads terminate themselves without Abort or Interrupt.

The 2 others are more annoying - and possibly mono bugs/issues.

Sockets can be closed in 2 ways - you can call Shutdown on them or you can call Close.

Calling Shutdown - works on one platform and crashes on the other.
Calling Close - crashes on one platform and works on the other
(DUH!!!)
Calling both at the same time turns out to the "the fix".

This is only true for UDP sockets - on TCP it works without issues.

Will send a bug report to Unity about this - see what they can do about it.

Grrrrrr - very annoying.


3) There is now code in place that should not give you multiple UDP_INIT if UDP was successfully initiated. If you get UDP_INIT callback with success = true multiple times, then something else is wrong. Might have lost UDP connection for some reason and the API tries to reconnect.

If you got a small repro case for this - or for the loosing responsiveness, then please send it to me and I'll trace it.

Thanks for testing - and keep reporting if you run into any issues!

/Thomas
vooood
Posts: 45
Joined: 08 Oct 2010, 09:04
Location: Croatia
Contact:

Postby vooood » 26 Dec 2010, 15:33

This problem is not solved in RC1b+FPSTutorial? I get it crashing all over again...
Music was my first love, and it will be my last
Music of the future, and music of the past
To live without my music would be impossible to do
In this world of trauma my music pulls me through
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 26 Dec 2010, 15:39

Should be all fixed with the updated dll - unless we packaged it wrong.

/Thomas
vooood
Posts: 45
Joined: 08 Oct 2010, 09:04
Location: Croatia
Contact:

Postby vooood » 26 Dec 2010, 15:56

ThomasLund wrote:Should be all fixed with the updated dll - unless we packaged it wrong.

/Thomas


with the original package and dll from sf2x update unity crashes after the demo is stopped. it also won't connect with the latest dll provided in this forum thread...
Music was my first love, and it will be my last

Music of the future, and music of the past

To live without my music would be impossible to do

In this world of trauma my music pulls me through
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 27 Dec 2010, 07:29

Will give it a spin later today now that xmas vacation is almost over. I have been fiddling in that part of the code to remove excess debug messages, so might have re-introduced the issue on Windows by accident.

*sigh*

/Thomas
matrix211v1
Posts: 61
Joined: 16 Jan 2009, 14:48

Postby matrix211v1 » 30 Dec 2010, 00:51

I agree. I had to use the SmartFox2-20101130.dll to get it to connect to 2X.

The one that is packaged with the "new" build doesn't work. I downloaded it 29/12/2010
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 30 Dec 2010, 12:08

Try this one:

http://www.fullcontrol.dk/downloads/SFS ... 101230.dll

It fixes a potential problem with shutdown - I was over eager to remove the debug spam on shutdown, so actually sometimes the correct disconnect code would not be called.
ghellere
Posts: 2
Joined: 11 Jan 2011, 18:13

Postby ghellere » 11 Jan 2011, 18:24

ThomasLund, I think there is stilll a problem when closing the UDP connection, in the the debug log below, I connect to the server, login, initiate UDP, join a room, spawn the character then I use

Code: Select all

smartFox.Send( new LogoutRequest() );


debug log:

Code: Select all

On Connection callback got: True (error : <>)
Sending login request
Logged in successfully

UDP ok
Joined game room Game
Spawn request sent to Game
Player Instantiated
OnLogout
[SFS - ERROR] UDPSocketLayer: Error reading data from socket: A blocking operation was interrupted by a call to WSACancelBlockingCall.

[SFS DEBUG] UDPSocketLayer: Error reading data from socket: A blocking operation was interrupted by a call to WSACancelBlockingCall.

[SFS DEBUG] UDPSocketLayer: Error reading data from socket: A blocking operation was interrupted by a call to WSACancelBlockingCall.

[SFS - WARN] Unexpected UDP I/O Error. Error reading data from socket: A blocking operation was interrupted by a call to WSACancelBlockingCall.

 [Interrupted]

[SFS DEBUG] Unexpected UDP I/O Error. Error reading data from socket: A blocking operation was interrupted by a call to WSACancelBlockingCall.

 [Interrupted]
[SFS DEBUG] Unexpected UDP I/O Error. Error reading data from socket: A blocking operation was interrupted by a call to WSACancelBlockingCall.

 [Interrupted]

OnConnectionLost
[SFS - ERROR] TCPSocketLayer: Connection closed by the remote side

[SFS DEBUG] TCPSocketLayer: Connection closed by the remote side
[SFS DEBUG] TCPSocketLayer: Connection closed by the remote side
[SFS DEBUG] TCPSocketLayer: Connection closed by the remote side


as you can see I get a "Unexpected UDP I/O Error. Error reading data from socket: A blocking operation was interrupted by a call to WSACancelBlockingCall." when I logout.

I've tried to stop sending packets to the server and then logout but I still got the error.

Client:
Windows 7 64bit
Unity 3.1 (with the latest dll posted by you)

Server:
Windows server 2008
SFS RC1a
Secret-V
Posts: 3
Joined: 11 Jan 2011, 18:34

Postby Secret-V » 11 Jan 2011, 18:41

I've got the same error message, in the FPS demo. I can login, I can chat, I can create a game room, but then it doesn't do anything. I see the red crosshair, but after a few seconds it returns to the login and the debugger says:

Code: Select all

User Left.

[SFS - DEBUG] UDPSocketLayer: Error reading data from socket: A blocking operation was interrupted by a call to WSACancelBlockingCall.

[SFS - DEBUG] Unexpected UDP I/O Error. Error reading data from socket: A blocking operation was interrupted by a call to WSACancelBlockingCall.


I'm also running Windows 7 64-bit with Unity 3.1.0f4
ghellere
Posts: 2
Joined: 11 Jan 2011, 18:13

Postby ghellere » 11 Jan 2011, 22:47

Secret-V wrote:I've got the same error message, in the FPS demo. I can login, I can chat, I can create a game room, but then it doesn't do anything. I see the red crosshair, but after a few seconds it returns to the login and the debugger says:

Code: Select all

User Left.

[SFS - DEBUG] UDPSocketLayer: Error reading data from socket: A blocking operation was interrupted by a call to WSACancelBlockingCall.

[SFS - DEBUG] Unexpected UDP I/O Error. Error reading data from socket: A blocking operation was interrupted by a call to WSACancelBlockingCall.


I'm also running Windows 7 64-bit with Unity 3.1.0f4


did you load the server Extension correctly? Did you enabled SFS to listen to 9933 UDP, and set the firewall?

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 6 guests