mit JSON-Daten senden Ich versuche, JSON-Daten zu senden mit Sockel, sondern erhalten diesen FehlerWie SSL
b'HTTP/0.9 413 anfordern Wesen zu groß \ r \ nserver: inets/5.10 .2 \ r \ nDatum: Fr, 05 Aug 2016 18:19:38 GMT \ r \ nContent-Type: text/html \ r \ nContent-Length: 202 \ r \ n \ r \ n '
mein Code:
def single_contract(amount, service_key):
current_date = datetime.now()
fee = 0
if amount > 10000.0:
fee = amount * 0.01
if os.path.exists('./Files/Point.txt'):
with open('./Files/Point.txt') as opened_file:
point_id = opened_file.read()
json_data = dict()
json_data["single_contract"] = dict()
json_data["single_contract"]["point_id"] = point_id.strip()
json_data["single_contract"]["datetime"] = datetime.strftime(current_date, '%Y-%m-%d %H:%M:%S')
json_data["single_contract"]["external_transaction_id"] = randint(999999999, 9999999999)
json_data["single_contract"]["service_id"] = 1001351861392575516
json_data["single_contract"]["amount"] = amount
json_data["single_contract"]["service_key"] = service_key
json_data["single_contract"]["fee"] = round(fee, 2)
json_data["single_contract"]["params"] = None
with open('./Files/sending_file.json', mode='w', encoding='utf-8') as json_file:
json.dump(json_data, json_file)
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sslcontext = ssl.create_default_context(purpose=ssl.Purpose.SERVER_AUTH)
sslcontext.load_verify_locations('./Files/ca-cert.pem')
sslcontext.load_cert_chain(certfile='./Files/com-cert.pem',
keyfile='./Files/com-key.pem')
host = '***.***.***.***'
port = ****
ssl_socket = sslcontext.wrap_socket(sock, server_hostname=host)
ssl_socket.connect((host, port))
with open('./Files/sending_file.json', mode='rb') as f:
ssl_socket.sendfile(f)
with open('./Files/answer.txt', mode='w', encoding='utf-8') as reply:
reply.write(str(ssl_socket.recv()))
ssl_socket.close()
print('End of connection')
else:
print('No such file or directory.')
Was bin ich d stimmt das nicht? Danke
Die Einzüge in Ihrem Code Look vermasselt. – jmdeamer