I'm having an error at the end of the execution of a thread on PHP. I take some youtube links from a RabbitMQ queue and try to download it with youtube-dl but it returns the following error right after the first thread ends:
PHP Fatal error: Uncaught exception 'PhpAmqpLibExceptionAMQPIOException' with message 'Error reading data. Received 0 instead of expected 7 bytes' in /home/eliecer/Vídeos/php-thread-master/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Wire/IO/StreamIO.php:161
Here is the receiver code that is causing the error
require_once("Thread.php");
require_once("ThreadQueue.php");
require_once __DIR__ . '/vendor/autoload.php';
use PhpAmqpLibConnectionAMQPConnection;
function paralel( $name ,$id) {
echo "Iniciando", "n";
$title= shell_exec('youtube-dl --get-filename -o "%(title)s.%(ext)s" '.$name);
$f ='youtube-dl -o "/home/eliecer/Documentos/%(title)s.%(ext)s" '.$name;
shell_exec($f);
echo "FInalizado", "n";
// HERE IS WHERE IT FAILS
}
$connection = new AMQPConnection('localhost', 5672, 'ernarvaezm', '12345678');
$channel = $connection->channel();
$channel->queue_declare('videos_queue', false, false, false, false);
echo ' * Waiting for messages. To exit press CTRL+C', "n";
$callback = function($msg){
$t1 = new Thread('paralel');
$data = json_decode($msg->body, true);
$t1->start($data['link'],$data['id']);
$msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']);
};
$channel->basic_qos(null, 1, null);
$channel->basic_consume('videos_queue', '', false, false, false, false, $callback);
while(count($channel->callbacks)) {
$channel->wait();
}
$channel->close();
$connection->close();
Any ideas why this error might be about?
Aucun commentaire:
Enregistrer un commentaire