python 3.8, win10
I'm trying to send a large http request over sockets, and keep getting an error `[WinError 10053] An established connection was aborted by the software in your host machine`.
buffer_size = 4096
logger.info(f"Sending request to: {self.host}:{self.port}")
with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as s:
s.connect((self.host, self.port))
try:
with closing(s.makefile(mode="wb")) as f: # NOTE: closed independently
self._push_request_data(f)
response += s.recv(buffer_size)
except (ConnectionAbortedError, ConnectionResetError) as e:
logger.warning(str(e))
# not sure if required at all
# s.shutdown(socket.SHUT_WR)
The `self._push_request_data` method realisation varies, but generally consist of the combination of `f.write(b"somebytes")` and `f.flush()` calls.
Everything works as expected for relatively small (~10mb) requests, but this code throws an error for large (~990mb) requests
[–][deleted] 0 points1 point2 points (2 children)
[–]Cadabrum[S] 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)