Example failed
seedgabo opened this issue · 8 comments
after the copy all the code from the example the onConnect Works, but when i send a message, i received a message on the server console: Trying to get a property of non object
Can you give me more information about the issue, stacktrace in your config?
Laravel 5.4
[2017-03-03 21:53:51] debug.ERROR: ErrorException: Trying to get property of non-object in C:\xampp\htdocs\newton\vendor\codemash\laravel-socket\src\Clients.php:17
Stack trace:
#0 C:\xampp\htdocs\newton\vendor\codemash\laravel-socket\src\Clients.php(17): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8, 'Trying to get p...', 'C:\xampp\htdocs...', 17, Array)
#1 [internal function]: Codemash\Socket\Clients->Codemash\Socket{closure}(Object(Codemash\Socket\Client), 622)
#2 C:\xampp\htdocs\newton\vendor\laravel\framework\src\Illuminate\Support\Arr.php(147): call_user_func(Object(Closure), Object(Codemash\Socket\Client), 622)
#3 C:\xampp\htdocs\newton\vendor\laravel\framework\src\Illuminate\Support\Collection.php(425): Illuminate\Support\Arr::first(Array, Object(Closure), NULL)
#4 C:\xampp\htdocs\newton\vendor\codemash\laravel-socket\src\Clients.php(18): Illuminate\Support\Collection->first(Object(Closure))
#5 C:\xampp\htdocs\newton\vendor\codemash\laravel-socket\src\MessageComponent.php(69): Codemash\Socket\Clients->findByConnection(Object(Ratchet\WebSocket\Version\RFC6455\Connection))
#6 C:\xampp\htdocs\newton\vendor\cboden\ratchet\src\Ratchet\WebSocket\Version\RFC6455.php(204): Codemash\Socket\MessageComponent->onMessage(Object(Ratchet\WebSocket\Version\RFC6455\Connection), '{"command":"sen...')
#7 C:\xampp\htdocs\newton\vendor\cboden\ratchet\src\Ratchet\WebSocket\WsServer.php(96): Ratchet\WebSocket\Version\RFC6455->onMessage(Object(Ratchet\WebSocket\Version\RFC6455\Connection), '\x81\xAEu\\xD5d\x0E~\xB6\v\x181\xB4\n\x11...')
#8 C:\xampp\htdocs\newton\vendor\cboden\ratchet\src\Ratchet\Http\HttpServer.php(53): Ratchet\WebSocket\WsServer->onMessage(Object(Ratchet\Server\IoConnection), '\x81\xAEu\\xD5d\x0E~\xB6\v\x181\xB4\n\x11...')
#9 C:\xampp\htdocs\newton\vendor\cboden\ratchet\src\Ratchet\Server\IoServer.php(113): Ratchet\Http\HttpServer->onMessage(Object(Ratchet\Server\IoConnection), '\x81\xAEu\\xD5d\x0E~\xB6\v\x181\xB4\n\x11...')
#10 [internal function]: Ratchet\Server\IoServer->handleData('\x81\xAEu\\xD5d\x0E~\xB6\v\x181\xB4\n\x11...', Object(React\Socket\Connection))
#11 C:\xampp\htdocs\newton\vendor\evenement\evenement\src\Evenement\EventEmitterTrait.php(64): call_user_func_array(Array, Array)
#12 C:\xampp\htdocs\newton\vendor\react\stream\src\Stream.php(173): Evenement\EventEmitter->emit('data', Array)
#13 [internal function]: React\Stream\Stream->handleData(Resource id #622, Object(React\EventLoop\StreamSelectLoop))
#14 C:\xampp\htdocs\newton\vendor\react\event-loop\src\StreamSelectLoop.php(232): call_user_func(Array, Resource id #622, Object(React\EventLoop\StreamSelectLoop))
#15 C:\xampp\htdocs\newton\vendor\react\event-loop\src\StreamSelectLoop.php(201): React\EventLoop\StreamSelectLoop->waitForStreamActivity(NULL)
#16 C:\xampp\htdocs\newton\vendor\cboden\ratchet\src\Ratchet\Server\IoServer.php(85): React\EventLoop\StreamSelectLoop->run()
#17 C:\xampp\htdocs\newton\vendor\codemash\laravel-socket\src\Server.php(65): Ratchet\Server\IoServer->run()
#18 C:\xampp\htdocs\newton\vendor\codemash\laravel-socket\src\Commands\Listen.php(41): Codemash\Socket\Server->run()
#19 [internal function]: Codemash\Socket\Commands\Listen->handle()
#20 C:\xampp\htdocs\newton\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(28): call_user_func_array(Array, Array)
#21 C:\xampp\htdocs\newton\vendor\laravel\framework\src\Illuminate\Support\helpers.php(912): Illuminate\Container\BoundMethod::Illuminate\Container{closure}()
#22 C:\xampp\htdocs\newton\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(86): value(Object(Closure))
#23 C:\xampp\htdocs\newton\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(30): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#24 C:\xampp\htdocs\newton\vendor\laravel\framework\src\Illuminate\Container\Container.php(524): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#25 C:\xampp\htdocs\newton\vendor\laravel\framework\src\Illuminate\Console\Command.php(182): Illuminate\Container\Container->call(Array)
#26 C:\xampp\htdocs\newton\vendor\symfony\console\Command\Command.php(262): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#27 C:\xampp\htdocs\newton\vendor\laravel\framework\src\Illuminate\Console\Command.php(167): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#28 C:\xampp\htdocs\newton\vendor\symfony\console\Application.php(826): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#29 C:\xampp\htdocs\newton\vendor\symfony\console\Application.php(189): Symfony\Component\Console\Application->doRunCommand(Object(Codemash\Socket\Commands\Listen), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#30 C:\xampp\htdocs\newton\vendor\symfony\console\Application.php(120): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#31 C:\xampp\htdocs\newton\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php(123): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#32 C:\xampp\htdocs\newton\artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#33 {main}
I have not yet checked support for Laravel 5.4 but it "should" be compatible. I'll try and replicate your issue as soon as I can (probably tomorrow). Meanwhile, feel free to explore the issue.
if i could help more:
this is the object $this received on findByConnection on clients.php
{"622":{"id":622,"connection":{},"ip":"127.0.0.1","session_manager":{"session":{}}}}
and this is the objecto from $connection in the same file
{}
i think i solved the error, on laravel 5.4 the signature for Collection::first is
($value,$key), you have on your Clients.php ($key,$value)
You're correct, this is a change introduced in 5.3. Can you verify this is a fix? I'll run a few tests tomorrow to make sure the change is a valid fix.
I am having the same issue.....
Resolved this issue by changing findByConnection function in
vendor\codemash\laravel-socket\src\Clients.php
:
public function findByConnection($connection) {
return $this->first(function ($client, $key) use ($connection) {
return $client->connection === $connection;
});
}
but need this change in resitory too