can't receive SFSEvent.SOCKET_ERROR event

Post here your questions about the Java client / Android API for SFS2X

Moderators: Lapo, Bax

maomao
Posts: 18
Joined: 08 Nov 2011, 04:48

can't receive SFSEvent.SOCKET_ERROR event

Postby maomao » 13 Mar 2012, 04:19

android client code

Code: Select all

   private void initSmartFoxEventHandler(){
      SmartFoxClient.addEventHandler(SFSEvent.LOGIN,this);
      SmartFoxClient.addEventHandler(SFSEvent.LOGIN_ERROR,this);
      SmartFoxClient.addEventHandler(SFSEvent.CONNECTION,this);
      SmartFoxClient.addEventHandler(SFSEvent.SOCKET_ERROR,this);
      //SmartFoxClient.addEventHandler("OnError",this);
      //SmartFoxClient.addEventHandler("ioError",this);
      //SmartFoxClient.getmSmartFox().
   }

exception

Code: Select all

02-07 21:00:26.100: W/System.err(2936): 272046 [New I/O client boss #1] ERROR sfs2x.client.core.sockets.TCPSocketLayer - TCPSocketLayer: Socket error: Connection refused
02-07 21:00:26.100: W/System.err(2936): 272051 [New I/O client boss #1] INFO sfs2x.client.core.EventDispatcher - Dispatching event OnError to 1 listeners
02-07 21:00:26.110: W/System.err(2936): 272055 [New I/O client boss #1] INFO sfs2x.client.core.EventDispatcher - Dispatching event ioError to 1 listeners
02-07 21:00:31.310: W/eChannelUpstreamHandler(2936): EXCEPTION, please implement sfs2x.client.bitswarm.bbox.BBClient$HttpResponseHandler.exceptionCaught() for proper handling.
02-07 21:00:31.310: W/eChannelUpstreamHandler(2936): java.nio.channels.ClosedChannelException
02-07 21:00:31.310: W/eChannelUpstreamHandler(2936):    at org.jboss.netty.channel.socket.nio.NioWorker.cleanUpWriteBuffer(NioWorker.java:649)
02-07 21:00:31.310: W/eChannelUpstreamHandler(2936):    at org.jboss.netty.channel.socket.nio.NioWorker.writeFromUserCode(NioWorker.java:370)
02-07 21:00:31.310: W/eChannelUpstreamHandler(2936):    at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink.eventSunk(NioClientSocketPipelineSink.java:117)
02-07 21:00:31.310: W/eChannelUpstreamHandler(2936):    at org.jboss.netty.channel.Channels.write(Channels.java:632)
02-07 21:00:31.310: W/eChannelUpstreamHandler(2936):    at org.jboss.netty.handler.codec.oneone.OneToOneEncoder.handleDownstream(OneToOneEncoder.java:70)
02-07 21:00:31.310: W/eChannelUpstreamHandler(2936):    at org.jboss.netty.handler.codec.http.HttpClientCodec.handleDownstream(HttpClientCodec.java:82)
02-07 21:00:31.310: W/eChannelUpstreamHandler(2936):    at org.jboss.netty.channel.Channels.write(Channels.java:611)
02-07 21:00:31.310: W/eChannelUpstreamHandler(2936):    at org.jboss.netty.channel.Channels.write(Channels.java:578)
02-07 21:00:31.310: W/eChannelUpstreamHandler(2936):    at org.jboss.netty.channel.AbstractChannel.write(AbstractChannel.java:259)
02-07 21:00:31.310: W/eChannelUpstreamHandler(2936):    at sfs2x.client.bitswarm.bbox.BBClient$1BBChannelFutureListener.operationComplete(BBClient.java:327)
02-07 21:00:31.310: W/eChannelUpstreamHandler(2936):    at org.jboss.netty.channel.DefaultChannelFuture.notifyListener(DefaultChannelFuture.java:381)
02-07 21:00:31.310: W/eChannelUpstreamHandler(2936):    at org.jboss.netty.channel.DefaultChannelFuture.notifyListeners(DefaultChannelFuture.java:372)
02-07 21:00:31.310: W/eChannelUpstreamHandler(2936):    at org.jboss.netty.channel.DefaultChannelFuture.setFailure(DefaultChannelFuture.java:334)
02-07 21:00:31.310: W/eChannelUpstreamHandler(2936):    at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.connect(NioClientSocketPipelineSink.java:389)
02-07 21:00:31.310: W/eChannelUpstreamHandler(2936):    at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.processSelectedKeys(NioClientSocketPipelineSink.java:354)
02-07 21:00:31.310: W/eChannelUpstreamHandler(2936):    at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.run(NioClientSocketPipelineSink.java:276)
02-07 21:00:31.310: W/eChannelUpstreamHandler(2936):    at org.jboss.netty.util.internal.IoWorkerRunnable.run(IoWorkerRunnable.java:46)
02-07 21:00:31.310: W/eChannelUpstreamHandler(2936):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
02-07 21:00:31.310: W/eChannelUpstreamHandler(2936):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
02-07 21:00:31.310: W/eChannelUpstreamHandler(2936):    at java.lang.Thread.run(Thread.java:1019)
02-07 21:00:31.349: W/eChannelUpstreamHandler(2936): EXCEPTION, please implement sfs2x.client.bitswarm.bbox.BBClient$HttpResponseHandler.exceptionCaught() for proper handling.
02-07 21:00:31.349: W/eChannelUpstreamHandler(2936): java.net.ConnectException: Connection refused
02-07 21:00:31.349: W/eChannelUpstreamHandler(2936):    at org.apache.harmony.luni.platform.OSNetworkSystem.isConnected(Native Method)
02-07 21:00:31.349: W/eChannelUpstreamHandler(2936):    at dalvik.system.BlockGuard$WrappedNetworkSystem.isConnected(BlockGuard.java:301)
02-07 21:00:31.349: W/eChannelUpstreamHandler(2936):    at org.apache.harmony.nio.internal.SocketChannelImpl.finishConnect(SocketChannelImpl.java:268)
02-07 21:00:31.349: W/eChannelUpstreamHandler(2936):    at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.connect(NioClientSocketPipelineSink.java:384)
02-07 21:00:31.349: W/eChannelUpstreamHandler(2936):    at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.processSelectedKeys(NioClientSocketPipelineSink.java:354)
02-07 21:00:31.349: W/eChannelUpstreamHandler(2936):    at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.run(NioClientSocketPipelineSink.java:276)
02-07 21:00:31.349: W/eChannelUpstreamHandler(2936):    at org.jboss.netty.util.internal.IoWorkerRunnable.run(IoWorkerRunnable.java:46)
02-07 21:00:31.349: W/eChannelUpstreamHandler(2936):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
02-07 21:00:31.349: W/eChannelUpstreamHandler(2936):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
02-07 21:00:31.349: W/eChannelUpstreamHandler(2936):    at java.lang.Thread.run(Thread.java:1019)


when i execute mSmartFox.connect(mIp, mPort) again i got this information

Code: Select all

02-07 21:03:40.159: W/System.err(2936): 466097 [Thread-13] WARN sfs2x.client.SmartFox - A connection attempt is already running



so ,please help me how can i receive SFSEvent.SOCKET_ERROR event?
think you!
User avatar
Bax
Site Admin
Posts: 4517
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: can't receive SFSEvent.SOCKET_ERROR event

Postby Bax » 13 Mar 2012, 15:02

If there's a connection error, the SFSEvent.CONNECTION event is fired, with a negative result in its parameters.
Also, if connection over socket failed and BlueBox is active, the client will try to connect via BlueBox before, eventually, fire the connection failed event.
Paolo Bax
The SmartFoxServer Team
maomao
Posts: 18
Joined: 08 Nov 2011, 04:48

Re: can't receive SFSEvent.SOCKET_ERROR event

Postby maomao » 14 Mar 2012, 01:38

when i don't start the smartfoxserver yet and i send connection request,but there is nothing event be response,i think there should connection error event or others be response
User avatar
Bax
Site Admin
Posts: 4517
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: can't receive SFSEvent.SOCKET_ERROR event

Postby Bax » 14 Mar 2012, 09:32

Yes, if SFS is not running you get a CONNECTION event with the success parameter set to false.
This may take some seconds (up to 20-30) because by default the client also tries to connect via BlueBox (http) and the timeout can take such long time.
Paolo Bax
The SmartFoxServer Team
maomao
Posts: 18
Joined: 08 Nov 2011, 04:48

Re: can't receive SFSEvent.SOCKET_ERROR event

Postby maomao » 14 Mar 2012, 14:20

yeah i know,but i wait more than one minute,there is nothing event to response,i don't know why?
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Re: can't receive SFSEvent.SOCKET_ERROR event

Postby ThomasLund » 16 Mar 2012, 16:31

Seems there is a bug in that case where the server isnt up at all. BB client doesnt properly catch that case and sends a callback. It only prints the error in the log and thats it.

I've put that on my little list to fix for next release.

Thanks for reporting!

/Thomas
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 Java / Android API”

Who is online

Users browsing this forum: No registered users and 2 guests