Sending Connection Options with AutobahnConnection() with Autobahn for Android

40 views
Skip to first unread message

TVanVuren

unread,
Jul 13, 2016, 7:47:04 PM7/13/16
to Autobahn
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);
    }
    
 });
   } ....

David Ford

unread,
Jul 13, 2016, 9:40:22 PM7/13/16
to autob...@googlegroups.com
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.

--
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

TVanVuren

unread,
Jul 14, 2016, 9:48:44 AM7/14/16
to Autobahn
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!
Reply all
Reply to author
Forward
0 new messages