summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changes/bug_increase_retries_logout2
-rw-r--r--src/leap/bitmask/crypto/srpauth.py18
2 files changed, 18 insertions, 2 deletions
diff --git a/changes/bug_increase_retries_logout b/changes/bug_increase_retries_logout
new file mode 100644
index 00000000..a3d1458b
--- /dev/null
+++ b/changes/bug_increase_retries_logout
@@ -0,0 +1,2 @@
+ o Increase the amount of retries for the authentication request
+ session. Fixes #4037. \ No newline at end of file
diff --git a/src/leap/bitmask/crypto/srpauth.py b/src/leap/bitmask/crypto/srpauth.py
index cbff4b49..47ed21b0 100644
--- a/src/leap/bitmask/crypto/srpauth.py
+++ b/src/leap/bitmask/crypto/srpauth.py
@@ -25,6 +25,7 @@ import json
#this error is raised from requests
from simplejson.decoder import JSONDecodeError
from functools import partial
+from requests.adapters import HTTPAdapter
from PySide import QtCore
from twisted.internet import threads
@@ -154,7 +155,8 @@ class SRPAuth(QtCore.QObject):
self._ng = self._srp.NG_1024
# **************************************************** #
- self._session = self._fetcher.session()
+ self._reset_session()
+
self._session_id = None
self._session_id_lock = QtCore.QMutex()
self._uid = None
@@ -172,6 +174,18 @@ class SRPAuth(QtCore.QObject):
self._username = None
self._password = None
+ def _reset_session(self):
+ """
+ Resets the current session and sets max retries to 30.
+ """
+ self._session = self._fetcher.session()
+ # We need to bump the default retries, otherwise logout
+ # fails most of the times
+ # NOTE: This is a workaround for the moment, the server
+ # side seems to return correctly every time, but it fails
+ # on the client end.
+ self._session.mount('https://', HTTPAdapter(max_retries=30))
+
def _safe_unhexlify(self, val):
"""
Rounds the val to a multiple of 2 and returns the
@@ -508,7 +522,7 @@ class SRPAuth(QtCore.QObject):
self._username = username
self._password = password
- self._session = self._fetcher.session()
+ self._reset_session()
d = threads.deferToThread(self._authentication_preprocessing,
username=username,