kivy.network.urlrequest import UrlRequest: Sending images of 1MB results in aiohttp.web_exceptions.HTTPRequestEntityTooLarge: Request Entity Too Large

18 views
Skip to first unread message

Gary Kuipers

unread,
Mar 22, 2023, 6:38:56 PM3/22/23
to Kivy users support
My image capture app based on  

Is running into a: aiohttp.web_exceptions.HTTPRequestEntityTooLarge: Request Entity Too Large error at the server even though the images are a mere 1MB in sise.

It must be self-inflicted. I have 2 phones, one was sending the images just fine, the otehr had the error. Whlie trashing about for hours trying to dig into what the server is receiving I must have done something, now neitehr phone can succesfully send images.

The sender code is:
def send_image(self, dir, filename):
fqpn = f"{dir}/{filename}"
self.log(3, f"Sender: send_image: requested to send {fqpn} *********************************************")
# send_daemon: processing /storage/emulated/0/DCIM/C4K+GPS/process filename=SQU~20230226061221~36_5450732~-87_2878151.jpg
img_b64 = self.get_base64_encoded_image(fqpn)
# Send the image data to the server using UrlRequest
data = {'image': img_b64, 'image_name': filename, 'method': 'base64', 'phone_id': self.phone_id}
headers = {'Content-type': 'application/json'}
self.log(4, f"Sender: send_image: to URL: {self.send_to_url}")
UrlRequest(self.send_to_url, on_success=self.send_image_on_success, on_failure=self.send_image_on_failure,
on_error=self.send_image_on_error, req_body=json.dumps(data), req_headers=headers)
print(f"Sender: send_image: to URL: sent")

The receiver code is:
async def web_post_handler(request):
data = None
print(f"web_post_handler receives request={request}")
try:
data = await request.json()
except Exception as e:
traceback.print_exc()
print(f"web_post_handler: ERROR {e}")
# respond fail
return

The error occurs at the try: data = await request.json()the print in the exception prints the error

ElliotG

unread,
Mar 22, 2023, 9:42:11 PM3/22/23
to Kivy users support
I don't have a clue.  I have not used aiohttp, it looks like a server side/aiohttp issue. 
Reply all
Reply to author
Forward
Message has been deleted
0 new messages