Skip to content

Commit

Permalink
Retry on SSLWantReadError and SSLWantWriteError
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinavsingh committed Nov 5, 2021
1 parent 677d845 commit d785681
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions proxy/plugin/reverse_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
:copyright: (c) 2013-present by Abhinav Singh and contributors.
:license: BSD, see LICENSE for more details.
"""
import ssl
import random
import socket
import logging
Expand Down Expand Up @@ -96,6 +97,9 @@ def read_from_descriptors(self, r: Readables) -> bool:
self.client.queue(raw)
else:
return True # Teardown because upstream server closed the connection
except ssl.SSLWantReadError:
logger.info('Upstream server SSLWantReadError, will retry')
return False
except ConnectionResetError:
logger.debug('Connection reset by upstream server')
return True
Expand All @@ -105,6 +109,9 @@ def write_to_descriptors(self, w: Writables) -> bool:
if self.upstream and self.upstream.connection in w and self.upstream.has_buffer():
try:
self.upstream.flush()
except ssl.SSLWantWriteError:
logger.info('Upstream server SSLWantWriteError, will retry')
return False
except BrokenPipeError:
logger.debug(
'BrokenPipeError when flushing to upstream server',
Expand Down

0 comments on commit d785681

Please sign in to comment.