From 106cc8f364a4672d221bb6ea75b179e83b4b14c0 Mon Sep 17 00:00:00 2001 From: Anatoly Legkodymov Date: Tue, 26 Nov 2013 01:30:27 +0400 Subject: [PATCH] HTTP persistent connection don't reconnect to bitcoind if server dies/restart --- bitcoinrpc/authproxy.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bitcoinrpc/authproxy.py b/bitcoinrpc/authproxy.py index 2914477..575c024 100644 --- a/bitcoinrpc/authproxy.py +++ b/bitcoinrpc/authproxy.py @@ -105,14 +105,21 @@ def __call__(self, *args): 'method': self.__service_name, 'params': args, 'id': self.__id_count}) - self.__conn.request('POST', self.__url.path, postdata, + try: + self.__conn.request('POST', self.__url.path, postdata, {'Host': self.__url.hostname, 'User-Agent': USER_AGENT, + 'Connection': 'close', 'Authorization': self.__auth_header, 'Content-type': 'application/json'}) + except: + self.__conn.close() + return None; response = self._get_response() + self.__conn.close() if response['error'] is not None: + print("AAA error: ", response['error']) raise JSONRPCException(response['error']) elif 'result' not in response: raise JSONRPCException({