I use Debian (nginx + pgsql). WebSockets is running and working ok. The /laravel-websockets dashboard shows statistics. But data is not being stored in database, to table "websockets_statistics_entries". This is the error log I'm getting:
[2020-05-31 10:16:46] staging.ERROR: SQLSTATE[23502]: Not null violation: 7 ERROR: null value in column "id" violates not-null constraint
DETAIL: Failing row contains (null, 1622200, 0, 1, 0, 2020-05-31 10:16:46, 2020-05-31 10:16:46). (SQL: insert into "websockets_statistics_entries" ("app_id", "peak_connection_count", "websocket_message_count", "api_message_count", "updated_at", "created_at") values (1622200, 0, 1, 0, 2020-05-31 10:16:46, 2020-05-31 10:16:46) returning "id") {"exception":"[object] (Illuminate\\Database\\QueryException(code: 23502): SQLSTATE[23502]: Not null violation: 7 ERROR: null value in column \"id\" violates not-null constraint
DETAIL: Failing row contains (null, 1622200, 0, 1, 0, 2020-05-31 10:16:46, 2020-05-31 10:16:46). (SQL: insert into \"websockets_statistics_entries\" (\"app_id\", \"peak_connection_count\", \"websocket_message_count\", \"api_message_count\", \"updated_at\", \"created_at\") values (1622200, 0, 1, 0, 2020-05-31 10:16:46, 2020-05-31 10:16:46) returning \"id\") at /var/www/dev.1auksion.uz/public_html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664, Doctrine\\DBAL\\Driver\\PDOException(code: 23502): SQLSTATE[23502]: Not null violation: 7 ERROR: null value in column \"id\" violates not-null constraint
DETAIL: Failing row contains (null, 1622200, 0, 1, 0, 2020-05-31 10:16:46, 2020-05-31 10:16:46). at /var/www/dev.1auksion.uz/public_html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:119, PDOException(code: 23502): SQLSTATE[23502]: Not null violation: 7 ERROR: null value in column \"id\" violates not-null constraint
DETAIL: Failing row contains (null, 1622200, 0, 1, 0, 2020-05-31 10:16:46, 2020-05-31 10:16:46). at /var/www/dev.1auksion.uz/public_html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:117)
[stacktrace]
App domain and websockets URL are the same. "enable_statistics" is set to false. Setting it true or false doesn't make any difference. "perform_dns_lookup" was set to true. Tried turning it to false with no luck - the issue persists.
My domain uses SSL.
I can't get events logging into the database or the dashboard displaying stats.
My (local) domain is working, over SSL and everything else is working fine.
Just cant get anything "logged"
From my websockets.php
'apps' => [
[
'id' => env('PUSHER_APP_ID'),
'name' => env('APP_NAME'),
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'path' => env('PUSHER_APP_PATH'),
'capacity' => null,
'enable_client_messages' => false,
'enable_statistics' => true
],
],
The last entry is the only thing I need?
(database table is migrated but remains empty)
Do you have a full stacktrace?
php artisan websockets:serve
Starting the WebSocket server on port 6001...
New connection opened for app key test.
Connection id 964013684.572254140 sending message {"event":"pusher:connection_established","data":"{\"socket_id\":\"964013684.572254140\",\"activity_timeout\":30}"}
Connection id 964013684.572254140 closed.
New connection opened for app key test.
Connection id 967424146.836475011 sending message {"event":"pusher:connection_established","data":"{\"socket_id\":\"967424146.836475011\",\"activity_timeout\":30}"}
trataka: connection id 967424146.836475011 received message: {"event":"pusher:subscribe","data":{"auth":"test:79676cd4a324cc909c39e705b30233ba8b123e5bfcf87e9ed4bcdf29f3a2386a","channel":"private-event.1"}}.
Connection id 967424146.836475011 sending message {"event":"pusher_internal:subscription_succeeded","channel":"private-event.1"}
trataka: connection id 967424146.836475011 received message: {"event":"pusher:ping","data":{}}.
Connection id 967424146.836475011 sending message {"event":"pusher:pong"}
Connection id 967424146.836475011 closed.
New connection opened for app key test.
Connection id 408333544.249585848 sending message {"event":"pusher:connection_established","data":"{\"socket_id\":\"408333544.249585848\",\"activity_timeout\":30}"}
trataka: connection id 408333544.249585848 received message: {"event":"pusher:subscribe","data":{"auth":"test:119b46eb3ad0749df40f259d0877b5a147c3a9f7b07433c3dfd274ea1088bb35","channel":"private-event.1"}}.
Connection id 408333544.249585848 sending message {"event":"pusher_internal:subscription_succeeded","channel":"private-event.1"}
Connection id 408333544.249585848 closed.
New connection opened for app key test.
Connection id 647944543.200202030 sending message {"event":"pusher:connection_established","data":"{\"socket_id\":\"647944543.200202030\",\"activity_timeout\":30}"}
trataka: connection id 647944543.200202030 received message: {"event":"pusher:ping","data":{}}.
Connection id 647944543.200202030 sending message {"event":"pusher:pong"}
trataka: connection id 647944543.200202030 received message: {"event":"pusher:ping","data":{}}.
Connection id 647944543.200202030 sending message {"event":"pusher:pong"}
trataka: connection id 647944543.200202030 received message: {"event":"pusher:ping","data":{}}.
Connection id 647944543.200202030 sending message {"event":"pusher:pong"}
trataka: connection id 647944543.200202030 received message: {"event":"pusher:ping","data":{}}.
Connection id 647944543.200202030 sending message {"event":"pusher:pong"}
trataka: connection id 647944543.200202030 received message: {"event":"pusher:ping","data":{}}.
Connection id 647944543.200202030 sending message {"event":"pusher:pong"}
trataka: connection id 647944543.200202030 received message: {"event":"pusher:ping","data":{}}.
Connection id 647944543.200202030 sending message {"event":"pusher:pong"}
trataka: connection id 647944543.200202030 received message: {"event":"pusher:ping","data":{}}.
Connection id 647944543.200202030 sending message {"event":"pusher:pong"}
trataka: connection id 647944543.200202030 received message: {"event":"pusher:ping","data":{}}.
Connection id 647944543.200202030 sending message {"event":"pusher:pong"}
trataka: connection id 647944543.200202030 received message: {"event":"pusher:ping","data":{}}.
Connection id 647944543.200202030 sending message {"event":"pusher:pong"}
trataka: connection id 647944543.200202030 received message: {"event":"pusher:ping","data":{}}.
Connection id 647944543.200202030 sending message {"event":"pusher:pong"}
trataka: connection id 647944543.200202030 received message: {"event":"pusher:ping","data":{}}.
Connection id 647944543.200202030 sending message {"event":"pusher:pong"}
trataka: connection id 647944543.200202030 received message: {"event":"pusher:ping","data":{}}.
Connection id 647944543.200202030 sending message {"event":"pusher:pong"}
trataka: connection id 647944543.200202030 received message: {"event":"pusher:ping","data":{}}.
Connection id 647944543.200202030 sending message {"event":"pusher:pong"}
trataka: connection id 647944543.200202030 received message: {"event":"pusher:ping","data":{}}.
Connection id 647944543.200202030 sending message {"event":"pusher:pong"}
Connection id 647944543.200202030 closed.
New connection opened for app key test.
Connection id 589119797.950165921 sending message {"event":"pusher:connection_established","data":"{\"socket_id\":\"589119797.950165921\",\"activity_timeout\":30}"}
Connection id 589119797.950165921 closed.
New connection opened for app key test.
Connection id 242429886.157453340 sending message {"event":"pusher:connection_established","data":"{\"socket_id\":\"242429886.157453340\",\"activity_timeout\":30}"}
Connection id 242429886.157453340 closed.
New connection opened for app key test.
Connection id 386061830.678212815 sending message {"event":"pusher:connection_established","data":"{\"socket_id\":\"386061830.678212815\",\"activity_timeout\":30}"}
trataka: connection id 386061830.678212815 received message: {"event":"pusher:ping","data":{}}.
Connection id 386061830.678212815 sending message {"event":"pusher:pong"}
trataka: connection id 386061830.678212815 received message: {"event":"pusher:ping","data":{}}.
Connection id 386061830.678212815 sending message {"event":"pusher:pong"}
New connection opened for app key test.
Connection id 992330266.20040139 sending message {"event":"pusher:connection_established","data":"{\"socket_id\":\"992330266.20040139\",\"activity_timeout\":30}"}
trataka: connection id 992330266.20040139 received message: {"event":"pusher:subscribe","data":{"auth":"test:d150810551d66a66c8a4c90902b8a488ee515b4b6977f251abdc76800a5f24fb","channel":"private-websockets-dashboard-client-message"}}.
Connection id 992330266.20040139 sending message {"event":"pusher_internal:subscription_succeeded","channel":"private-websockets-dashboard-client-message"}
trataka: connection id 992330266.20040139 received message: {"event":"pusher:subscribe","data":{"auth":"test:051e370e158a8b0cdd2537a20ce7f659e708a3932ed85a1695cb676567437ed4","channel":"private-websockets-dashboard-vacated"}}.
Connection id 992330266.20040139 sending message {"event":"pusher_internal:subscription_succeeded","channel":"private-websockets-dashboard-vacated"}
trataka: connection id 992330266.20040139 received message: {"event":"pusher:subscribe","data":{"auth":"test:60f7fe4817b3d8e1cd9431a93d06e028152d6d53ac523824408a1fd6e44dfd29","channel":"private-websockets-dashboard-connection"}}.
Connection id 992330266.20040139 sending message {"event":"pusher_internal:subscription_succeeded","channel":"private-websockets-dashboard-connection"}
trataka: connection id 992330266.20040139 received message: {"event":"pusher:subscribe","data":{"auth":"test:b9e90c3bc3fb6c9ff68fc8bc67bc260344667d51c87af32f1f4a7bebebf1495a","channel":"private-websockets-dashboard-disconnection"}}.
Connection id 992330266.20040139 sending message {"event":"pusher_internal:subscription_succeeded","channel":"private-websockets-dashboard-disconnection"}
trataka: connection id 992330266.20040139 received message: {"event":"pusher:subscribe","data":{"auth":"test:8847e3a7f754a08212c9a6cb72ca2161c26677a1e06ecb6cdf658c1d846b17f9","channel":"private-websockets-dashboard-occupied"}}.
Connection id 992330266.20040139 sending message {"event":"log-message","channel":"private-websockets-dashboard-occupied","data":{"type":"occupied","time":"10:07:08","details":"Channel: private-websockets-dashboard-occupied"}}
Connection id 992330266.20040139 sending message {"event":"pusher_internal:subscription_succeeded","channel":"private-websockets-dashboard-occupied"}
trataka: connection id 992330266.20040139 received message: {"event":"pusher:subscribe","data":{"auth":"test:52cb213192dd25c79c96f5afb31f93bd2f38def81bf53c9a04f160cd739863dd","channel":"private-websockets-dashboard-subscribed"}}.
Connection id 992330266.20040139 sending message {"event":"log-message","channel":"private-websockets-dashboard-occupied","data":{"type":"occupied","time":"10:07:08","details":"Channel: private-websockets-dashboard-subscribed"}}
Connection id 992330266.20040139 sending message {"event":"log-message","channel":"private-websockets-dashboard-subscribed","data":{"type":"subscribed","time":"10:07:08","socketId":"992330266.20040139","details":"Channel: private-websockets-dashboard-subscribed"}}
Connection id 992330266.20040139 sending message {"event":"pusher_internal:subscription_succeeded","channel":"private-websockets-dashboard-subscribed"}
trataka: connection id 992330266.20040139 received message: {"event":"pusher:subscribe","data":{"auth":"test:f21529591a48f768a34c456fcc332fd600c83a319a2691c3a2753f8a6b7e4127","channel":"private-websockets-dashboard-statistics"}}.
Connection id 992330266.20040139 sending message {"event":"log-message","channel":"private-websockets-dashboard-occupied","data":{"type":"occupied","time":"10:07:08","details":"Channel: private-websockets-dashboard-statistics"}}
Connection id 992330266.20040139 sending message {"event":"log-message","channel":"private-websockets-dashboard-subscribed","data":{"type":"subscribed","time":"10:07:08","socketId":"992330266.20040139","details":"Channel: private-websockets-dashboard-statistics"}}
Connection id 992330266.20040139 sending message {"event":"pusher_internal:subscription_succeeded","channel":"private-websockets-dashboard-statistics"}
trataka: connection id 992330266.20040139 received message: {"event":"pusher:subscribe","data":{"auth":"test:6d791907bfc030507aa77bdd2cdcafafd2b60d3945897875713703ffb7ee3d73","channel":"private-websockets-dashboard-api-message"}}.
Connection id 992330266.20040139 sending message {"event":"log-message","channel":"private-websockets-dashboard-occupied","data":{"type":"occupied","time":"10:07:08","details":"Channel: private-websockets-dashboard-api-message"}}
Connection id 992330266.20040139 sending message {"event":"log-message","channel":"private-websockets-dashboard-subscribed","data":{"type":"subscribed","time":"10:07:08","socketId":"992330266.20040139","details":"Channel: private-websockets-dashboard-api-message"}}
Connection id 992330266.20040139 sending message {"event":"pusher_internal:subscription_succeeded","channel":"private-websockets-dashboard-api-message"}
trataka: connection id 386061830.678212815 received message: {"event":"pusher:ping","data":{}}.
Connection id 386061830.678212815 sending message {"event":"pusher:pong"}
trataka: connection id 992330266.20040139 received message: {"event":"pusher:ping","data":{}}.
Connection id 992330266.20040139 sending message {"event":"pusher:pong"}
trataka: connection id 386061830.678212815 received message: {"event":"pusher:ping","data":{}}.
Connection id 386061830.678212815 sending message {"event":"pusher:pong"}
trataka: connection id 992330266.20040139 received message: {"event":"pusher:ping","data":{}}.
Connection id 992330266.20040139 sending message {"event":"pusher:pong"}
trataka: connection id 386061830.678212815 received message: {"event":"pusher:ping","data":{}}.
Connection id 386061830.678212815 sending message {"event":"pusher:pong"}
trataka: connection id 992330266.20040139 received message: {"event":"pusher:ping","data":{}}.
Connection id 992330266.20040139 sending message {"event":"pusher:pong"}
trataka: connection id 386061830.678212815 received message: {"event":"pusher:ping","data":{}}.
Connection id 386061830.678212815 sending message {"event":"pusher:pong"}
trataka: connection id 992330266.20040139 received message: {"event":"pusher:ping","data":{}}.
Connection id 992330266.20040139 sending message {"event":"pusher:pong"}
trataka: connection id 386061830.678212815 received message: {"event":"pusher:ping","data":{}}.
Connection id 386061830.678212815 sending message {"event":"pusher:pong"}
trataka: connection id 992330266.20040139 received message: {"event":"pusher:ping","data":{}}.
Connection id 992330266.20040139 sending message {"event":"pusher:pong"}
trataka: connection id 386061830.678212815 received message: {"event":"pusher:ping","data":{}}.
Connection id 386061830.678212815 sending message {"event":"pusher:pong"}
trataka: connection id 992330266.20040139 received message: {"event":"pusher:ping","data":{}}.
Connection id 992330266.20040139 sending message {"event":"pusher:pong"}
trataka: connection id 386061830.678212815 received message: {"event":"pusher:ping","data":{}}.
Connection id 386061830.678212815 sending message {"event":"pusher:pong"}
trataka: connection id 992330266.20040139 received message: {"event":"pusher:ping","data":{}}.
Connection id 992330266.20040139 sending message {"event":"pusher:pong"}
trataka: connection id 386061830.678212815 received message: {"event":"pusher:ping","data":{}}.
Connection id 386061830.678212815 sending message {"event":"pusher:pong"}
trataka: connection id 992330266.20040139 received message: {"event":"pusher:ping","data":{}}.
Connection id 992330266.20040139 sending message {"event":"pusher:pong"}
trataka: connection id 386061830.678212815 received message: {"event":"pusher:ping","data":{}}.
Connection id 386061830.678212815 sending message {"event":"pusher:pong"}
trataka: connection id 992330266.20040139 received message: {"event":"pusher:ping","data":{}}.
Connection id 992330266.20040139 sending message {"event":"pusher:pong"}
trataka: connection id 386061830.678212815 received message: {"event":"pusher:ping","data":{}}.
Connection id 386061830.678212815 sending message {"event":"pusher:pong"}
trataka: connection id 992330266.20040139 received message: {"event":"pusher:ping","data":{}}.
Connection id 992330266.20040139 sending message {"event":"pusher:pong"}
trataka: connection id 386061830.678212815 received message: {"event":"pusher:ping","data":{}}.
Connection id 386061830.678212815 sending message {"event":"pusher:pong"}
trataka: connection id 992330266.20040139 received message: {"event":"pusher:ping","data":{}}.
Connection id 992330266.20040139 sending message {"event":"pusher:pong"}
trataka: connection id 386061830.678212815 received message: {"event":"pusher:ping","data":{}}.
Connection id 386061830.678212815 sending message {"event":"pusher:pong"}
trataka: connection id 992330266.20040139 received message: {"event":"pusher:ping","data":{}}.
Connection id 992330266.20040139 sending message {"event":"pusher:pong"}
trataka: connection id 386061830.678212815 received message: {"event":"pusher:ping","data":{}}.
Connection id 386061830.678212815 sending message {"event":"pusher:pong"}
trataka: connection id 992330266.20040139 received message: {"event":"pusher:ping","data":{}}.
Connection id 992330266.20040139 sending message {"event":"pusher:pong"}
trataka: connection id 386061830.678212815 received message: {"event":"pusher:ping","data":{}}.
Connection id 386061830.678212815 sending message {"event":"pusher:pong"}
Can you post the migration file that creates the table?
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateWebSocketsStatisticsEntriesTable extends Migration
{
/**
* Run the migrations.
*/
public function up()
{
Schema::create('websockets_statistics_entries', function (Blueprint $table) {
$table->increments('id');
$table->string('app_id');
$table->integer('peak_connection_count');
$table->integer('websocket_message_count');
$table->integer('api_message_count');
$table->nullableTimestamps();
});
}
/**
* Reverse the migrations.
*/
public function down()
{
Schema::dropIfExists('websockets_statistics_entries');
}
}
Laravel Version?
LOL
It was "a version 7" and I've just updated (everything) with composer (so Laravel is now 7.25.0)
But now it's broken!!!!
php artisan websockets:serve
Starting the WebSocket server on port 6001...
New connection opened for app key test.
Connection id 333126282.478988101 sending message {"event":"pusher:connection_established","data":"{\"socket_id\":\"333126282.478988101\",\"activity_timeout\":30}"}
Error
Class 'BeyondCode\LaravelWebSockets\Statistics\Logger' not found
at vendor/beyondcode/laravel-websockets/src/Console/StartWebSocketServer.php:65
61|
62| app()->singleton(StatisticsLoggerInterface::class, function () use ($browser) {
63| $class = config('websockets.statistics.logger', \BeyondCode\LaravelWebSockets\Statistics\Logger::class);
64|
> 65| return new $class(app(ChannelManager::class), $browser);
66| });
67|
68| $this->loop->addPeriodicTimer(config('websockets.statistics.interval_in_seconds'), function () {
69| StatisticsLogger::save();
+42 vendor frames
43 artisan:37
Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
Process finished with exit code 1.
Just go in the config file and add this logger to the statistics:
'statistics' => [
'logger' => \BeyondCode\LaravelWebSockets\Statistics\Logger\HttpStatisticsLogger::class,
]
@blakeyman The issue was a temporary one, you can upgrade to 1.5.1 to be fixed automatically, regardless of the logger set.
a) still nothing logged to database
b) now the dashboard no longer shows activity in (events) list
nb: it has never displayed real-time statistics either
Pushed 1.5.2 with the fixes.
Still nothing logged to db
Events List is back (still no real-time graph)
Interestingly this should be https:gfs (I'm developing locally)
Where is dashboard getting this data from?

From dashboard.blade.php
wsHost: this.app.host === null ? window.location.hostname : this.app.host,
Should this be using location.protocol as well?
That's not the connected host, it's the origin - where the connection actually comes from.
Have you checked https://github.com/beyondcode/laravel-websockets/issues/270 ?
Most helpful comment
Just go in the config file and add this
loggerto thestatistics: