Sending Connection Options with AutobahnConnection() with Autobahn for Android

#1

I’m testing code very similar to what is in the Autobahn documentation for subscribing to a PubSub topic using AutobahnConnection(). My connection works great and I get the data back from my event handler just fine. However, the connection is timing out after a few minutes. How do I get the WebSocket options into the connection so I can increase/remove the connection timeout or is it better to just ping the server every 30 seconds from the client to keep the connection alive? Thanks in advance for any help!!

final AutobahnConnection mConnection = new AutobahnConnection();

private void connectToServer() {

	WebSocketOptions options = new WebSocketOptions();

	options.setSocketConnectTimeout(0);

	mConnection.connect(wsuri, new Autobahn.SessionHandler() {

	    @Override

	    public void onOpen() {

	       Log.d(TAG, "Status: Connected to " + wsuri);

	       connectRealTimeServer();

	    }

	    @Override

	    public void onClose(int code, String reason) {

	       Log.d(TAG, "Connection lost:  Code: "+code+" Reason:" + reason);

	    }

	 });

   } ....
0 Likes

#2

for crossbar’s config.json, add this:

workers->transports->paths->ws->options: auto_ping_interval (in milliseconds).

i.e.:

},

“options”: {

“auto_ping_interval”: 10000,

“auto_ping_timeout”: 21000,

}

this will ping your clients every 10 seconds and a client won’t ping out unless they go for two ping cycles without responding.

···

On Wed, Jul 13, 2016 at 11:47 PM, TVanVuren to...@buyerkiosk.com wrote:

I’m testing code very similar to what is in the Autobahn documentation for subscribing to a PubSub topic using AutobahnConnection(). My connection works great and I get the data back from my event handler just fine. However, the connection is timing out after a few minutes. How do I get the WebSocket options into the connection so I can increase/remove the connection timeout or is it better to just ping the server every 30 seconds from the client to keep the connection alive? Thanks in advance for any help!!

final AutobahnConnection mConnection = new AutobahnConnection();

private void connectToServer() {

  WebSocketOptions options = new WebSocketOptions();
  options.setSocketConnectTimeout(0);
  mConnection.connect(wsuri, new Autobahn.SessionHandler() {
      @Override
      public void onOpen() {
         Log.d(TAG, "Status: Connected to " + wsuri);
         connectRealTimeServer();
      }
      @Override
      public void onClose(int code, String reason) {
         Log.d(TAG, "Connection lost:  Code: "+code+" Reason:" + reason);
      }
   });
 } ....

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.

To post to this group, send email to autob...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/autobahnws/e4f044e8-a7ef-4ae5-968e-83e5c9e01a94%40googlegroups.com.

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

Gay/FireRescue/Geek in 33484, USA
It’s the ideals of Linux and Open Source that are amazing, it embodies what WE want, not what is marketed

0 Likes

#3

David - thanks for the post. I’m not a crossbar user and was looking for a way to do this in the Android source code using the connection string. Sounds like ping may be the better way to go though. Thanks for taking the time to post!

···

On Wednesday, July 13, 2016 at 8:40:22 PM UTC-5, David Ford wrote:

for crossbar’s config.json, add this:

workers->transports->paths->ws->options: auto_ping_interval (in milliseconds).

i.e.:

},

“options”: {

“auto_ping_interval”: 10000,

“auto_ping_timeout”: 21000,

}

this will ping your clients every 10 seconds and a client won’t ping out unless they go for two ping cycles without responding.

On Wed, Jul 13, 2016 at 11:47 PM, TVanVuren to...@buyerkiosk.com wrote:

I’m testing code very similar to what is in the Autobahn documentation for subscribing to a PubSub topic using AutobahnConnection(). My connection works great and I get the data back from my event handler just fine. However, the connection is timing out after a few minutes. How do I get the WebSocket options into the connection so I can increase/remove the connection timeout or is it better to just ping the server every 30 seconds from the client to keep the connection alive? Thanks in advance for any help!!

final AutobahnConnection mConnection = new AutobahnConnection();

private void connectToServer() {
  WebSocketOptions options = new WebSocketOptions();
  options.setSocketConnectTimeout(0);
  mConnection.connect(wsuri, new Autobahn.SessionHandler() {
      @Override
      public void onOpen() {
         Log.d(TAG, "Status: Connected to " + wsuri);
         connectRealTimeServer();
      }
      @Override
      public void onClose(int code, String reason) {
         Log.d(TAG, "Connection lost:  Code: "+code+" Reason:" + reason);
      }
   });
 } ....

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.

To post to this group, send email to auto...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/autobahnws/e4f044e8-a7ef-4ae5-968e-83e5c9e01a94%40googlegroups.com.

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


Gay/FireRescue/Geek in 33484, USA
It’s the ideals of Linux and Open Source that are amazing, it embodies what WE want, not what is marketed

0 Likes