How to check if autobahn connected to the server

#1

Hi!

I have this piece of code:

	socketConnection = new WebSocketConnection();

	try {

		socketConnection.connect(serverUri, new MyWebSocketHandler());

	} catch (WebSocketException e) {

		Log.d(TAG, e.toString());

		notifyAboutConnectionProblems();

	}

If server is unaccessible I want to be notified about this, but the problem is that when I turn off socket server authobahn just doesn’t do anything, it looks like code in catch clause is not executed at all. Is it intended behaviour?

I can create some timer and see if there is a connection in 3-5 seconds, but I would like to know if autobahn can do it for me.

0 Likes

#2

I’m using ab.connect() and it’s onhangup() function notifies you about disconnect’s and retries. This works very well for me.

···

On Mon, Aug 19, 2013 at 2:55 AM, Alexander Romanov alexander...@gmail.com wrote:

Hi!

I have this piece of code:

  socketConnection = new WebSocketConnection();
  try {
  	socketConnection.connect(serverUri, new MyWebSocketHandler());
  } catch (WebSocketException e) {
  	Log.d(TAG, e.toString());
  	notifyAboutConnectionProblems();
  }

If server is unaccessible I want to be notified about this, but the problem is that when I turn off socket server authobahn just doesn’t do anything, it looks like code in catch clause is not executed at all. Is it intended behaviour?

I can create some timer and see if there is a connection in 3-5 seconds, but I would like to know if autobahn can do it for me.

You received this message because you are subscribed to the Google Groups “Autobahn” group.

To unsubscribe from this group and stop receiving emails from it, send an email to autobahnws+...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.


Neville Franks, Author of Surfulater - Your off-line Digital Reference Library

Soft As It Gets Pty Ltd, http://www.surfulater.com - Download your copy now.

Victoria, Australia Blog: http://blog.surfulater.com

0 Likes

#3

Neville is correct in that AutobahnJS function ab.connect() will take care of connection timeouts and automatic reconnects.

However, I think Alexander was talking about AutobahnAndroid. But there is something similar there too. You nee to handle this in asynchronous callback "onclose", not in synchronous exception block:

https://github.com/tavendo/AutobahnAndroid/blob/master/Demo/EchoClient/src/de/tavendo/autobahn/echoclient/EchoClientActivity.java#L122

/Tobias

···

Am 19.08.2013 00:08, schrieb Neville Franks:

I'm using ab.connect() and it's onhangup() function notifies you about
disconnect's and retries. This works very well for me.

On Mon, Aug 19, 2013 at 2:55 AM, Alexander Romanov > <alexander...@gmail.com <mailto:alexander...@gmail.com>> wrote:

    Hi!

    I have this piece of code:
    socketConnection = new WebSocketConnection();

    try {
    socketConnection.connect(serverUri, new MyWebSocketHandler());
    } catch (WebSocketException e) {
    Log.d(TAG, e.toString());
    notifyAboutConnectionProblems();
    }

    If server is unaccessible I want to be notified about this, but the
    problem is that when I turn off socket server authobahn just doesn't
    do anything, it looks like code in catch clause is not executed at
    all. Is it intended behaviour?

    I can create some timer and see if there is a connection in 3-5
    seconds, but I would like to know if autobahn can do it for me.

    --
    You received this message because you are subscribed to the Google
    Groups "Autobahn" group.
    To unsubscribe from this group and stop receiving emails from it,
    send an email to autobahnws+...@googlegroups.com
    <mailto:autobahnws%2...@googlegroups.com>.
    For more options, visit https://groups.google.com/groups/opt_out.

--
Neville Franks, Author of Surfulater - Your off-line Digital Reference
Library
  Soft As It Gets Pty Ltd, http://www.surfulater.com - Download your
copy now.
  Victoria, Australia Blog: http://blog.surfulater.com

--
You received this message because you are subscribed to the Google
Groups "Autobahn" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to autobahnws+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Likes