-
Notifications
You must be signed in to change notification settings - Fork 235
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
sendFile not working #182
Comments
I have the same problem
nothing happens and even i get no error message |
Still no updates to this? |
@gsfordham @Darklandz Sorry for late reply, not sure about |
got the same problem and no error output .. got in the runRequest from httpdriver but my php coding experience is not that good :/ |
I can confirm this isn't working. I was trying both on version v4.* in composer.json as well as dev-develop. On v4.* the entire php process is crashing, on dev-develop it seems to be trying to send a file but it fails to submit the Promise.
The code is kept rather simple because I wasn't sure if my big project was broken. So I literally broke it down to: $discord = new Discord([
'token' => $token
]);
$discord->on('ready', function ($discord) {
echo "Bot is ready!", PHP_EOL;
// Listen for messages.
$discord->on('message', function ($message, $discord) {
$message->channel->sendFile('/srv/dphp/files/img_10F4b1C7ffQrPeo.jpg', 'img.jpg', 'Image', false)
->then(
function($msg) {
echo 'OKAY!';
die('Bye bye'); //Making sure it won't reply to itself!
})
->otherwise(
function($e) {
echo $e->getMessage() . PHP_EOL;
echo $e->getTraceAsString() . PHP_EOL;
});
});
});
$discord->run(); |
Okay, I shall reply myself here - this is something interesting. I was debugging into the error - and well, DiscordPHP is not to blame. This seems to be an error which only occurs on certain PHP configurations. I'm using Ubuntu 16.04 with Ondrej Sury's PHP PPA (see https://launchpad.net/~ondrej/+archive/ubuntu/php ). Personally I am thus using PHP 7.0.14 to run the bot. The bug affects the OpenSSL extension of PHP - I can reconstruct it in PHP 5.6, PHP 7.0 and PHP 7.1 - I created a separate PHP CLI client by recompiling Ondrej Sury's PHP CLI interpreter with the bug fix at PHP from https://bugs.php.net/bug.php?id=72333 included (not as /usr/bin/php but as /usr/bin/php_sslbot so that a future package upgrade wouldn't immediately overwrite it). The bug is also discussed at the ReactPHP GitHub see reactphp/stream#64 - so yeah, so far using this recompiled PHP works - I doubt this is a bug DiscordPHP can fix for affected PHP installations. |
For me, only files under 100 KB work. |
Yeah this still doesn't work, looks like PHP peeps aren't in a rush to fix it. |
@BuzzMoody "@ gsfordham @ darklandz Sorry for late reply, not sure about master but sendFile is working on the develop branch. I'll push a release to master sometime today. Is there another issue that I don't see?" |
Doesn't work on either branch on both Debian and Ubuntu. |
@haolink Able to share your recompiled PHP CLI client? |
I'm pretty sure that replacing fopen() with file_get_contents() will fix the issue, but it won't be as clean and I think file_get_contents() blocks or something |
The issue is finally fixed on the PHP upstream. See http://git.php.net/?p=php-src.git;a=commit;h=17e9fc9bfeaf575b25782a42937a56e809155858 @BuzzMoody - sorry I didn't notice your ping so I didn't react. The thing is: I can share the client but it's basically built from Ondrej Sury's PHP 7.0 builds - so it is linked against Ubuntu 16.04 and PHP 7.0 libraries by him - I tested on Vanilla Ubuntu 16.04 and like expected it didn't run - it ran into many missing libraries. So yeah: if you have such a configuration I can share the binary - if not it will probably be a waste of time - however, the upstream of PHP has it, so if you use quick release cycles you should have it rather soon ^^. |
Closing as this seems to be fixed with PHP. Working for me on develop branch. |
Still not working on Debian 10, PHP 7.4.10 and dev branch |
@BuzzMoody could you retry with the latest master? It got a few changes in the last past days |
"PHP Warning: array_key_exists() expects parameter 2 to be array, bool given in /home/buzz/DiscordPHP/vendor/team-reflex/discord-php/src/Discord/Http/Http.php on line 145" |
Line 145 on the |
Hey David, I updated to dev-master as you suggested. I now no longer get any errors it just won't send the image. No output, but keeps running fine. |
@BuzzMoody Could you update again please, just with |
It's working! You're a genius <3 |
So, the file won't let me rename it after running this. Says the file is OPEN with PHP, but the thing is: it doesn't send. When the file doesn't even exist, it sends an empty, 0kb file of name "test.jpg" and echos an error to my prompt, but when the file exists, it does nothing. At all. It doesn't write an error to my prompt, but it also doesn't send the file; it's as if it succeeded in sending it, but it didn't.
And it STILL responds afterward, so it's not hanging. It just opens the file, does nothing with it, and then continues.
Is there a different way I'm supposed to do this?
The text was updated successfully, but these errors were encountered: