From 4287ca91bfbfea89953c742ac3f1a9e97c84df25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 31 Oct 2018 08:30:47 +0100 Subject: [PATCH] Wait to be sure about the scheme before construct the bus URL issue7792 review54401002 --- CHANGELOG | 1 + tryton/bus.py | 7 ++++++- tryton/jsonrpc.py | 4 +++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 54859b6634..4bc98efed7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Ensure URL scheme of bus (issue7792) * Add drag & drop support on binary widget Version 5.0.0 - 2018-10-01 diff --git a/tryton/bus.py b/tryton/bus.py index abda4fcdbd..b804ac816f 100644 --- a/tryton/bus.py +++ b/tryton/bus.py @@ -34,7 +34,6 @@ def listen(connection): def _listen(connection): bus_timeout = CONFIG['client.bus_timeout'] session = connection.session - url = connection.url + '/bus' authorization = base64.b64encode(session.encode('utf-8')) headers = { 'Content-Type': 'application/json', @@ -43,7 +42,13 @@ def _listen(connection): wait = 1 last_message = None + url = None while connection.session == session: + if url is None: + if connection.url is None: + time.sleep(1) + continue + url = connection.url + '/bus' request = Request(url, data=json.dumps({ 'last_message': last_message, diff --git a/tryton/jsonrpc.py b/tryton/jsonrpc.py index 4de51eec93..90b3bbc865 100644 --- a/tryton/jsonrpc.py +++ b/tryton/jsonrpc.py @@ -340,10 +340,12 @@ class ServerPool(object): def ssl(self): for conn in self._pool + list(self._used.values()): return conn.ssl - return False + return None @property def url(self): + if self.ssl is None: + return None scheme = 'https' if self.ssl else 'http' return urljoin( scheme + '://' + self._host + ':' + str(self._port),