Statistics not storing to the database
Websockets working perfectly on local and production. Neither one is writing entries to the websockets_statitistics_entry table. I've tried changing perform_dns_lookup to true as well to no avail. Any suggestions?
+1. It seems that they broke something. it seems that this line:
71. $statistic->isEnabled()
will always return true. Source file: vendor\beyondcode\laravel-websockets\src\Statistics\Logger\HttpStatisticsLogger.php
Have you solved your issue?
I am having this issue as well.
I have not solved this issue yet, was hoping someone with more experience with the package had a solution.
I have not solved this issue yet, was hoping someone with more experience with the package had a solution.
I could try to solve it. But rn I have a very strict deadline for the project. It would be amazing if the devs would help with it.
I am having the same issue working on local machine and I solved it by changing APP_URL in .env
APP_URL=http://127.0.0.1:8000
I have the same problem. Strange that there are no errors around this in the laravel log.
I have the same problem. Strange that there are no errors around this in the laravel log.
I forgot to post my solution. The latest 1.x versions are broken on the statistics side of things. Go and use the beta 2.x versions and it will work like a charm. I am using it in prod for like 3 months and I saw no issues
I had the same problem here, but with Laravel 10, it iss not possible to use the beta versions. I can see that there is a fundamental redesign of Laravel-websockets 2.x concerning the Statistics but on 1.14 version this code does not work as attempted :
HttpStatisticsLogger.php -> Line 79
$this
->browser
->post(
action([WebSocketStatisticsEntriesController::class, 'store']),
['Content-Type' => 'application/json'],
Utils::streamFor(json_encode($postData))
);
everything seems correct except the $this->browser who probably should be misconfigured.
I actually succeeded to send a post request from Insomnia with the information in the $this->browser->post() method so the problem should probably be the poster.
And actually I found out it was not correctly configured as we can see here in StartWebSocketServer :
$connector = new Connector($this->loop, [
'dns' => $this->getDnsResolver(),
'tls' => [
'verify_peer' => config('app.env') === 'production',
'verify_peer_name' => config('app.env') === 'production',
],
]);
$browser = new Browser($this->loop, $connector);
If I replace $this->getDnsResolver() with 127.0.0.1 it works. So the problem comes from the Connecter receiving the 'dns' :
vendor/react/socket/src/Connector.php Line 93 :
if ($context['dns'] !== false)
{
if ($context['dns'] instanceof ResolverInterface)
{
$resolver = $context['dns'];
}
else
{
if ($context['dns'] !== true) {
$config = $context['dns'];
} else {
// try to load nameservers from system config or default to Google's public DNS
$config = DnsConfig::loadSystemConfigBlocking();
if (!$config->nameservers) {
$config->nameservers[] = '8.8.8.8'; // @codeCoverageIgnore
}
}
$factory = new DnsFactory();
$resolver = $factory->createCached(
$config,
$loop
);
}
if( $context['happy_eyeballs'] === true )
{
$tcp = new HappyEyeBallsConnector($loop, $tcp, $resolver);
}
else
{
$tcp = new DnsConnector($tcp, $resolver);
}
}
When focusing on the code, I figure out that the `happy_eyeballs [ always true when not indicated ] creates à new HappyEyeBallsConnctor instead of the DnsConnector normally working. So :
I tried to add a happy_eyeballs => false in the connector context array and it solved the problem.
$connector = new Connector($this->loop, [
'dns' => $this->getDnsResolver(),
'tls' => [
'verify_peer' => config('app.env') === 'production',
'verify_peer_name' => config('app.env') === 'production',
],
'happy_eyeballs' => false
]);
Hope this helps.