caronc / apprise-api

A lightweight REST framework that wraps the Apprise Notification Library
https://hub.docker.com/r/caronc/apprise
MIT License
575 stars 49 forks source link

Bad attachment warning for attachments > 10 MB #176

Closed zapatistay closed 3 months ago

zapatistay commented 4 months ago

I receive this warning message when I attach files > 10MB. No notification is relayed. The command I use is :

curl -k -X POST -F "title=xxx" -F "body=yyy." -F attach1=@/home/1.pdf "http://192.168.2.73:8001/notify/email"

and the log of the apprise docker container is as follows :

2024/03/09 03:00:19 [warn] 12#12: *12 a client request body is buffered to a temporary file /var/lib/nginx/body/0000000001, client: 192.168.2.7, server: , request: "POST /notify/email HTTP/1.1", host: "192.168.2.73:8001" 2024-03-08 18:00:19,741 [WARNING] django: NOTIFY - 127.0.0.1 - Bad attachment specified 2024-03-08 18:00:19,752 [WARNING] django.request: Bad Request: /notify/email

As one user previously suggested, I switched to the LSIO image but the same error persisted. I cannot attach files larger than 10 MB.

The apprise version is APPRISE v1.7.3 running as a docker container.

This error occur also when I use the NOTIFICATIONS tab to relay a message. So both CLI and the web app has the same error. I have checked read/write permissions on /var/lib/nginx/body and they are all rwx for all users ie chmodded to 777.

If there is a buffer or size limit on the attachment, how can I increase it?

caronc commented 4 months ago

Hmm, this is strange APPRISE_ATTACH_SIZE should be set to 200MB (see here, but you're saying in your instance it is not. Are you hosting Apprise behind your own version of Nginx? You may need to fix the issue here?

Let me know how that works out, otherwise i can investigate deeper into my the source code.

zapatistay commented 3 months ago

No, there are no nginx installed on this machine or any other docker container. I am not using a reverse proxy on my own.

I just specified APPRISE_ATTACH_SIZE to be equal to 200 in environment variables specifically, but the result did not change.

zapatistay commented 3 months ago

I changed the docker command to run it as PUID=0 and PGID=0, but the error still did not go away.

caronc commented 3 months ago

Try out the :edge docker branch; default is 200MB and bug you identified was fixed.

BTW, thank you for reporting this! :rocket: .

zapatistay commented 3 months ago

Do you mean lscr.io/linuxserver/apprise-api:edge or caronc/apprise:edge ?

caronc commented 3 months ago

caronc/apprise:edge

zapatistay commented 3 months ago

Hi Caron,

I've switched to edge build and now I get the following error when I try to send a pdf file 17MB big. Is this an apprise problem or a mail server problem? There are still no errors if I choose a file size less than 10MB. Only when > 10MB or so.

(private data redacted)

2024/03/14 10:08:13 [warn] 9#9: *74 a client request body is buffered to a temporary file /var/lib/nginx/body/0000000002, client: 192.168.2.7, server: , request: "POST /notify/xxxxxxx HTTP/1.1", host: "192.168.2.73:8001" 2024-03-14 02:08:13,977 [DEBUG] apprise: Language set to en 2024-03-14 02:08:13,977 [DEBUG] apprise: Loading raw configuration: mailtos://xxxxxxx.com?smtp=smtp.xxxxxxx.com&user=yyyyy@xxxxxxx.com&pass=zzzzzzzz 2024-03-14 02:08:13,978 [DEBUG] apprise: Loaded URL: mailtos://yyyyy:**@xxxxxxx.com/?format=html&overflow=upstream&rto=4.0&cto=15&verify=yes&smtp=smtp.xxxxxxx.com&mode=starttls 2024-03-14 02:08:13,978 [INFO] apprise: Loaded 1 entries from memory:// 2024-03-14 02:08:13,978 [DEBUG] apprise: Email From: Apprise yyyyy@xxxxxxx.com 2024-03-14 02:08:13,978 [DEBUG] apprise: Email To: yyyyy@xxxxxxx.com 2024-03-14 02:08:13,978 [DEBUG] apprise: Login ID: yyyyy@xxxxxxx.com 2024-03-14 02:08:13,978 [DEBUG] apprise: Delivery: smtp.xxxxxxx.com:587 2024-03-14 02:08:13,979 [DEBUG] apprise: Preparing Email attachment file:///attach/tmpemge6hoq?name=1.pdf 2024-03-14 02:08:17,595 [DEBUG] apprise: Connecting to remote SMTP server... 2024-03-14 02:08:17,986 [DEBUG] apprise: Securing connection with STARTTLS... 2024-03-14 02:08:18,765 [DEBUG] apprise: Applying user credentials... 2024-03-14 02:08:35,772 [WARNING] apprise: Sending email to "yyyyy@xxxxxxx.com" failed. Reason: Server not connected 2024-03-14 02:08:35,782 [ERROR] apprise: Unhandled Notification Exception Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/apprise/Apprise.py", line 582, in _notify_sequential result = server.notify(kwargs) ^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/apprise/plugins/NotifyBase.py", line 382, in notify the_calls = [self.send(kwargs2) for kwargs2 in send_calls] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/apprise/plugins/NotifyBase.py", line 382, in the_calls = [self.send(kwargs2) for kwargs2 in send_calls] ^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/apprise/plugins/NotifyEmail.py", line 847, in send return self.submit(messages) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/apprise/plugins/NotifyEmail.py", line 913, in submit socket.quit() File "/usr/local/lib/python3.11/smtplib.py", line 1004, in quit res = self.docmd("quit") ^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/smtplib.py", line 431, in docmd self.putcmd(cmd, args) File "/usr/local/lib/python3.11/smtplib.py", line 378, in putcmd self.send(f'{s}{CRLF}') File "/usr/local/lib/python3.11/smtplib.py", line 365, in send raise SMTPServerDisconnected('please run connect() first') smtplib.SMTPServerDisconnected: please run connect() first 2024-03-14 02:08:35,802 [WARNING] django: NOTIFY - 127.0.0.1 - One or more notifications not sent using KEY: xxxxxxx 2024-03-14 02:08:35,811 [WARNING] django.request: Failed Dependency: /notify/xxxxxxx 192.168.2.7 - - [14/Mar/2024:10:08:35 +0300] "POST /notify/xxxxxxx HTTP/1.1" 424 2518 "-" "curl/8.1.2" 2024/03/14 10:08:35 [info] 9#9: *74 client 192.168.2.7 closed keepalive connection

caronc commented 3 months ago

Looks like the SMTP server disconnected on you during the file transfer. But it died closing off the connection (something it does when it's finished and wrapping up). Does the attachment still send?

It does appear to be the server side at this point. The connection to Apprise will disconnect after 30s, it could be this too. You can increase the timeout with another environment variable to rule this out