Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal Error: Out Of Memory When i trying to send video #132

Closed
anajo333 opened this issue Feb 7, 2021 · 2 comments
Closed

Fatal Error: Out Of Memory When i trying to send video #132

anajo333 opened this issue Feb 7, 2021 · 2 comments
Labels
question Marks an PR or issue to be a question rather than code modification

Comments

@anajo333
Copy link

anajo333 commented Feb 7, 2021

Hello,
i using a lastest version from telegram-api

I want to upload video 192MB and
send it to my channel with examples/send-video.php
i change $sendVideo->video = new InputFile('binary-test-data/demo-video.mp4'); to my file
but this error faced me

fatal error: out of memory (allocated 1613365248) (tried to allocate 201413288 bytes) in /home/ooo/public_html/2/src/InternalFunctionality/PostOptionsConstructor.php

I added

ini_set('memory_limit', '-1');
ini_set('max_execution_time', 0);
set_time_limit(0);

in the top of scripts like

examples/send-video.php
examples/basics.php
src/InternalFunctionality/PostOptionsConstructor.php
examples/config.php
vendor/autoload.php

And this error still faced me
i tryed on too many servers
There's any solve for this problem

@DJTommek
Copy link
Contributor

DJTommek commented Mar 9, 2021

Your issue is your-server-related. I tried your example with 188mb file on notebook with 16 GB RAM and it went thru PHP just fine. I guess that you are limited by hardware capability provided on your server.

Anyway, even if you would solve out of memory issue, Telegram API is not accepting uploaded files that big, as you can see here: https://core.telegram.org/bots/api#sending-files

Post the file using multipart/form-data in the usual way that files are uploaded via the browser. 10 MB max size for photos, 50 MB for other files.

If you send file bigger than that, Telegram API will respond with:

413: Request Entity Too Large

And this library will throw this exception:

\unreal4u\TelegramAPI\Exceptions\ClientException: Request Entity Too Large #413

If you try something smaller (for example 2.9 MB) PHP will upload it correctly and Telegram will accept it as it should. Only solution that came up in my mind is using recently introduced Local Bot API Server, which increasing limit up to 2000 MB. According issue #129 it should be possible with this library but I didn't tested it, yet.

@unreal4u unreal4u added the question Marks an PR or issue to be a question rather than code modification label Mar 9, 2021
@unreal4u
Copy link
Owner

unreal4u commented Mar 9, 2021

Very good answer @DJTommek ! Thanks for answering this!

@unreal4u unreal4u closed this as completed Mar 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Marks an PR or issue to be a question rather than code modification
Projects
None yet
Development

No branches or pull requests

3 participants