Socket Error -> kill client for ever

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

udikantz
Posts: 153
Joined: 24 Sep 2009, 09:36

Socket Error -> kill client for ever

Postby udikantz » 28 Mar 2012, 12:56

Hello,
I am working on a sfs2x project and I have encountered a critical problem on the client side API.
The use case is as follows:

1. george is connected to MyServer
2. MyServer is being rebooted for some reason
3. george get notified with connection lost event
4. george is trying to reconnect while the server has not started yet
5. george receives the following errors:

Code: Select all

Error opening URL 'http://graph.facebook.com/I/picture?type=square'
## SocketError: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2031: Socket Error. URL: localhost"]
Error opening URL 'http://localhost:8080/BlueBox/BlueBox.do'
## BlueBox Error: Error #2032: Stream Error. URL: http://localhost:8080/BlueBox/BlueBox.do
## SecurityError: [SecurityErrorEvent type="securityError" bubbles=false cancelable=false eventPhase=2 text="Error #2048: Security sandbox violation: file:///C|/Projects/BubbleWorldClient/bin/LobbyV1.swf cannot load data from localhost:443."]

6.Server is going back up
7.george's client is stuck due to error in section 5 and cannot reconnect to game, only way to use the client API is by closing the client and reload it again.


I have tried to handle this socket error / ioerror events it seems that nothing can catch them,
When this error happens it kills the client with no option to revive it,

is there anyway to handle this use case please?
diwip games - co founder & CPO.

http://www.diwip.com
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Socket Error -> kill client for ever

Postby rjgtav » 28 Mar 2012, 13:23

Hello.
Are you sure you're using the latest Server version and Client API? You can download the latest API updates here.
And please check your api version by tracing the smartfox.version property.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
udikantz
Posts: 153
Joined: 24 Sep 2009, 09:36

Re: Socket Error -> kill client for ever

Postby udikantz » 28 Mar 2012, 18:09

Yes i am using the latest Client API which is not compatible with FlashDevelop make it hard to code.
diwip games - co founder & CPO.



http://www.diwip.com
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Socket Error -> kill client for ever

Postby rjgtav » 28 Mar 2012, 18:28

And how are you trying to reconnect? With the HRC system or by manually calling smartfox.connect()? If you're doing the 2nd case, I think you have to recreate the SmartFox object before trying to connect again.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
udikantz
Posts: 153
Joined: 24 Sep 2009, 09:36

Re: Socket Error -> kill client for ever

Postby udikantz » 29 Mar 2012, 08:20

I am using the 2nd way,
and i have tried to re create the smarfox client ,
it does not help. still the same results.
diwip games - co founder & CPO.



http://www.diwip.com
User avatar
Lapo
Site Admin
Posts: 21522
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Socket Error -> kill client for ever

Postby Lapo » 29 Mar 2012, 08:32

If the server is down you will get a connection error which is reported by the CONNECTION event, typically it will be an IOError because the other end is not responding.
When you get such error it's probably a better idea to show a clear message that says "Sorry, the server is not ready, please try in a couple of minutes", instead of firing one connection attempt after the other.
Also, if your application runs in the browser, you could simply provide a link that reloads the page so your application is restarted anew.
Lapo
--
gotoAndPlay()
...addicted to flash games
jorgicor
Posts: 6
Joined: 13 Feb 2012, 11:12
Location: Spain

Re: Socket Error -> kill client for ever

Postby jorgicor » 04 Apr 2012, 14:08

I'm getting exactly the same error. I have the last version of the client (1.0.3) and the server.

I stop the server, open a new client and try to connect. Of course, the client does not connect, but I get this error (on the client):

Code: Select all

## SocketError: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2031: Socket Error. URL: 127.0.0.1"]
Error opening URL 'http://127.0.0.1:8080/BlueBox/BlueBox.do'
## BlueBox Error: Error #2032: Stream Error. URL: http://127.0.0.1:8080/BlueBox/BlueBox.do
## SecurityError: [SecurityErrorEvent type="securityError" bubbles=false cancelable=false eventPhase=2 text="Error #2048: Security sandbox violation: file:///C|/juegos/FlashGame/src/bin/DebugLib/Juego.swf cannot load data from 127.0.0.1:9933."]


After that, I start the server and with the same client try to reconnect, and the client can't connect anymore. Every time I try to reconnect, with the server running, after some seconds I get on the client the SFSEvent.CONNECTION with success = false and the following is printed:

Code: Select all

Error opening URL 'http://127.0.0.1:9933/BlueBox/BlueBox.do'
## BlueBox Error: Error #2032: Stream Error. URL: http://127.0.0.1:9933/BlueBox/BlueBox.do


I have to say that on the server is printed:

Code: Select all

15:42:16,281 INFO  [SocketReader] core.SocketAcceptor     - Session created: { Id: 2, Type: DEFAULT, Logged: No, IP: 127.0.0.1:1899 } on Server port: 9933 <---> 1899


That is, the server gets the connection, but the client cannot connect anymore.

Note that this happens after the client tries to connect to a server and the server is not running. If with the cilent connected I stop the server, restart the server and reconnect with the same client, everything works ok.

Any idea? I don't thing that restarting the client is a good idea. This should work.

Thank you in advance
jorgicor
Posts: 6
Joined: 13 Feb 2012, 11:12
Location: Spain

Re: Socket Error -> kill client for ever

Postby jorgicor » 04 Apr 2012, 14:50

Update:

For now I have disabled BlueBox in the client ( .useBlueBox = false ) and now it works...
User avatar
Lapo
Site Admin
Posts: 21522
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Socket Error -> kill client for ever

Postby Lapo » 04 Apr 2012, 15:12

As I said earlier in this case the easiest way is to reset Flash so that it doesn't complain about the security problems.
Since this is a particular case, having the application reloaded should provide no harm.
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Socket Error -> kill client for ever

Postby rjgtav » 04 Apr 2012, 19:46

Hello.
Are you sure that re-creating the client doesn't help? I just created a test application, which after CONNECTION_LOST and CONNECTION (with success returning false) events creates a new SmartFox object and it works flawlessly.
I have been playiing with it by disconnecting, connecting normally, connecting via BlueBox, shutting down the server abruptly, etc... And the client hasn't stopped working yet...
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
jorgicor
Posts: 6
Joined: 13 Feb 2012, 11:12
Location: Spain

Re: Socket Error -> kill client for ever

Postby jorgicor » 05 Apr 2012, 07:59

Yes, I tried that solution too. I recreated the Smartfox object, the same problem. I don't know what we are doing different. I am running everything (client and server) on the same computer. The problem is when you try to connect and the server is down: after that if you restart the server and try to connect, the client does not connect anymore. If you are connected, you stop the server, restart it again and reconnect, everything works ok. If I disable bluebox the problem goes away.
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Socket Error -> kill client for ever

Postby rjgtav » 05 Apr 2012, 19:26

Hmm this is strange... Apparently that bug only happens on the browser... If I test the app on the Flash IDE, it always works, with no problems...
Will continue investigating...

[Update]
If I use the debug player WIN 11,2,202,228 on Chrome, it works flawlessly. But the common player (same version) hangs after the first connection error.
On IE, even the debug player gives problems...
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
tgwozdz
Posts: 17
Joined: 22 Jun 2012, 15:36

Re: Socket Error -> kill client for ever

Postby tgwozdz » 27 Jun 2012, 19:25

Does anyone have a solution to this problem? I'm seeing something similar:
- Try to connect to server which is offline. I see the security error message in the console for the SWF, but my OnConnection callback is never called with a failure.
- After disabling bluebox, I can now receive the OnConnection callback with a failure response.

Any idea how to resolve this? Currently my client waits forever in this case, since we don't hear success or failure from the connection attempt. Is there some other event we should be listening for in this case?
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Socket Error -> kill client for ever

Postby rjgtav » 28 Jun 2012, 10:20

Are you using the latest Client API?
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
tgwozdz
Posts: 17
Joined: 22 Jun 2012, 15:36

Re: Socket Error -> kill client for ever

Postby tgwozdz » 28 Jun 2012, 13:07

Yes, using 1.0.3.

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 5 guests