Event not triggered when connection fails

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

Moderators: Lapo, Bax

superdude
Posts: 18
Joined: 05 May 2013, 11:24

Event not triggered when connection fails

Postby superdude » 27 Jun 2013, 21:04

Hi,

I'm using the java API, and the dispatch(BaseEvent event) method triggers fine when a connection is successful, but when it fails (for example when SFS is not running) it does not. From what I can read on other threads it's still supposed to trigger the Connection event with the "failed" parameter even if SFS is not running, correct? It's not happening for me, not even when waiting for several minutes.

I get the errors below. Is it that the ClosedChannelException and ConnectException is somehow interrupting the event or something? How could I control this?

Thanks.

5669 [New I/O client boss #1] ERROR sfs2x.client.core.sockets.TCPSocketLayer - TCPSocketLayer: Socket error: Connection refused: no further information
5670 [New I/O client boss #1] INFO sfs2x.client.core.EventDispatcher - Dispatching event OnError to 1 listeners
5671 [New I/O client boss #1] INFO sfs2x.client.core.EventDispatcher - Dispatching event ioError to 1 listeners
2013-jun-27 22:12:17 org.jboss.netty.channel.SimpleChannelUpstreamHandler
VARNING: EXCEPTION, please implement sfs2x.client.bitswarm.bbox.BBClient$HttpResponseHandler.exceptionCaught() for proper handling.
java.nio.channels.ClosedChannelException
at org.jboss.netty.channel.socket.nio.NioWorker.cleanUpWriteBuffer(NioWorker.java:649)
at org.jboss.netty.channel.socket.nio.NioWorker.writeFromUserCode(NioWorker.java:370)
at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink.eventSunk(NioClientSocketPipelineSink.java:117)
at org.jboss.netty.channel.Channels.write(Channels.java:632)
at org.jboss.netty.handler.codec.oneone.OneToOneEncoder.handleDownstream(OneToOneEncoder.java:70)
at org.jboss.netty.handler.codec.http.HttpClientCodec.handleDownstream(HttpClientCodec.java:82)
at org.jboss.netty.channel.Channels.write(Channels.java:611)
at org.jboss.netty.channel.Channels.write(Channels.java:578)
at org.jboss.netty.channel.AbstractChannel.write(AbstractChannel.java:259)
at sfs2x.client.bitswarm.bbox.BBClient$1BBChannelFutureListener.operationComplete(BBClient.java:327)
at org.jboss.netty.channel.DefaultChannelFuture.notifyListener(DefaultChannelFuture.java:381)
at org.jboss.netty.channel.DefaultChannelFuture.notifyListeners(DefaultChannelFuture.java:372)
at org.jboss.netty.channel.DefaultChannelFuture.setFailure(DefaultChannelFuture.java:334)
at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.connect(NioClientSocketPipelineSink.java:389)
at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.processSelectedKeys(NioClientSocketPipelineSink.java:354)
at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.run(NioClientSocketPipelineSink.java:276)
at org.jboss.netty.util.internal.IoWorkerRunnable.run(IoWorkerRunnable.java:46)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
2013-jun-27 22:12:17 org.jboss.netty.channel.SimpleChannelUpstreamHandler
VARNING: EXCEPTION, please implement sfs2x.client.bitswarm.bbox.BBClient$HttpResponseHandler.exceptionCaught() for proper handling.
java.net.ConnectException: Connection refused: no further information
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(Unknown Source)
at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.connect(NioClientSocketPipelineSink.java:384)
at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.processSelectedKeys(NioClientSocketPipelineSink.java:354)
at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.run(NioClientSocketPipelineSink.java:276)
at org.jboss.netty.util.internal.IoWorkerRunnable.run(IoWorkerRunnable.java:46)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
User avatar
Lapo
Site Admin
Posts: 23025
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Event not triggered when connection fails

Postby Lapo » 28 Jun 2013, 06:30

Moved under the Client side section / Java API
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
Lapo
Site Admin
Posts: 23025
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Event not triggered when connection fails

Postby Lapo » 28 Jun 2013, 06:31

It sounds like you are using an older version of the API.
Please make sure to download the latest release, version 1.2.0

http://www.smartfoxserver.com/download/sfs2x#p=client

thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
superdude
Posts: 18
Joined: 05 May 2013, 11:24

Re: Event not triggered when connection fails

Postby superdude » 28 Jun 2013, 20:54

Yup that fixed it, thanks! By the way is it possible to set a connection time out, I mean how long it should keep trying to connect for before giving up?
User avatar
Lapo
Site Admin
Posts: 23025
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Event not triggered when connection fails

Postby Lapo » 29 Jun 2013, 08:07

That really depends on the underlying operating system, so there's no timeout setting to play with.
Normally the connection error should fire almost instantaneously. In presence of a firewall it may take a longer time, though.
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Java / Android API”

Who is online

Users browsing this forum: No registered users and 10 guests