Support the ongoing development of Laravel.io →
Queues Jobs Input

I am using Ratchet with laravel 4.1. I trying to pass the ratchet variables to the laravel job queue, but it shows serialization of 'closure' error when the $self variable is passed to the job queue. I am using 'barryvdh/laravel-async-queue' as the queue driver.

$self = $this->repository; 

Queue::push(function($job) use ($nom,$self)

The full code is give below:

   public function onClose(ConnectionInterface $conn) {

    try {
        // The connection is closed, remove it, as we can no longer send it messages
        //$this->clients->detach($conn);
        $currClient = $this->repository->getClientByConnection($conn);
        $nom = $currClient->getId();

        $this->repository->removeClient($conn);

        echo "Connection {$conn->resourceId} has disconnected\n";

        //print_r($this->repository->getClientById($nom)->getId());

        $self = $this->repository;
        print_r($self);
        Queue::push(function($job) use ($nom,$self)
        {
            Log::info($nom);

            $job->delete();
        });


    }
    catch (Exception $e) {
            Log::error('Chat->onClose->'.$e->getMessage());
    }
}
Last updated 3 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

winnyboy5 winnyboy5 Joined 14 Oct 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.