#2486 Added option to use websocket protocol options.
--- a/runtime/WampClient.py Tue Mar 27 10:11:04 2018 +0200
+++ b/runtime/WampClient.py Mon Apr 09 14:38:38 2018 +0200
@@ -26,6 +26,7 @@
from __future__ import print_function
import time
import json
+import inspect
from autobahn.twisted import wamp
from autobahn.twisted.websocket import WampWebSocketClientFactory, connectWS
from autobahn.wamp import types, auth
@@ -110,6 +111,25 @@
class ReconnectingWampWebSocketClientFactory(WampWebSocketClientFactory, ReconnectingClientFactory):
+ def __init__(self, config, *args, **kwargs):
+ WampWebSocketClientFactory.__init__(self, *args, **kwargs)
+
+ arguments = inspect.getargspec(self.setProtocolOptions).args
+ protocolOptions = config.extra.get('protocolOptions', None)
+
+ validProtocolOptions = {}
+
+ for key in protocolOptions:
+ if key in arguments:
+ validProtocolOptions[key] = protocolOptions[key]
+
+ if len(validProtocolOptions) > 0:
+ self.setProtocolOptions(**validProtocolOptions)
+ print(_("Added custom protocol options"))
+
+ del validProtocolOptions
+ del protocolOptions
+
def buildProtocol(self, addr):
self.resetDelay()
return ReconnectingClientFactory.buildProtocol(self, addr)
@@ -168,6 +188,7 @@
# create a WAMP-over-WebSocket transport client factory
transport_factory = ReconnectingWampWebSocketClientFactory(
+ component_config,
session_factory,
url=WSClientConf["url"],
serializers=[MsgPackSerializer()])
--- a/tests/wamp/project_files/wampconf.json Tue Mar 27 10:11:04 2018 +0200
+++ b/tests/wamp/project_files/wampconf.json Mon Apr 09 14:38:38 2018 +0200
@@ -3,5 +3,6 @@
"realm":"Automation",
"ID":"wamptest",
"password":"1234567890",
- "key":"ABCDEFGHIJ"
+ "key":"ABCDEFGHIJ",
+ "protocolOptions":{"autoPingTimeout":20, "autoPingInterval":60}
}