dimanche 25 novembre 2018

Outofmemory error tring debug MessageComponentInterface method vars

In my laravel 5.7 app I use MessageComponentInterface for chat app with a class like

<?php

namespace App\Classes\Socket;

use App\Classes\Socket\Base\BaseSocket;
use Ratchet\MessageComponentInterface;
use Ratchet\ConnectionInterface;

class ChatSocket extends BaseSocket
{
    protected $clients;

    public function __construct()
    {
        $this->clients = new \SplObjectStorage;
    }

    public function onOpen(ConnectionInterface $conn) {
        $this->clients->attach($conn);
        echo '<pre>New Connection ::'.print_r($conn->resourceId,true).'</pre>';
    }

    public function onMessage(ConnectionInterface $from, $msg) {
        $numRecv= count($this->clients)-1;
         echo '<pre>onMessage $msg::' . print_r( $msg, true ) ;
//        var_dump($from);
        dump($from);
        die("-1 XXZ000");
        echo '<pre>onMessage $from::' . print_r( $from, true ) ;
        ...

The problem is that in onMessage event I want to this message write to db table, but I can not find where to get user_id of user who sent this message? I tried to debug outputing values to screen with

echo '<pre>onMessage $from::' . print_r( $from, true ) ;

But I got outof memmory error, but in /etc/php/7.2/cli/php.ini I modified options:

max_execution_time = 3330
max_input_time = 240
memory_limit = 4048M

and restarted my server, but anyway I got outof memory error

using these metods:

//        var_dump($from);
        dump($from);

I got endless output in console and I could not catch anything...

How to debug these values ?

Thanks!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire