def rpc_call_raw(self, json_data, send_only=False):
"""
Send a raw JSON request to the server
This method does not validate the input JSON. Also you have to make sure
that if you send a request where the "id" parameter has the value "null"
the parameter send_only must be True. Otherwise the client will block
indefinitely because the server sees it as a notify request and does not
send an answer.
If we are currently not connected with the server this method will call
__connect() to create a connection.
Args:
json_data (str): The JSON that is sent to the server as is
send_only (bool): Only send the request, don't try to read a response
Returns:
str: The response string as returned by the server
None: If send_only is True
Raises:
NetworkError: Any network error
"""
try:
if not self.is_connected():
self.__connect()
retry_count = 0
json_reply = None
while True:
try:
self.send_request(json_data)
if send_only:
return
json_reply = self.receive_response()
break
except IOError as e:
if e.errno == errno.ECONNRESET and self.auto_reconnect and retry_count < 1:
retry_count += 1
self.__connect()
else:
raise e
return json_reply
except (ConnectionRefusedError, socket.error, SSLEOFError,
TLSHostnameError) as e:
self.close_connection()
raise NetworkError(e)
评论列表
文章目录