I have an issue with Websockets and my actuel websocket test project. No problems with my local project.
But when it comes to deploy on my Laravel Forge Server I get the :
app.js:41145 WebSocket connection to 'wss://my-domain:6002/app/my-app-key?protocol=7&client=js&version=7.0.0&flash=false' failed: Error in connection establishment: net::ERR_SSL_PROTOCOL_ERROR
I think it is important to indicate that I do not have implemented a Authentication on my project.
I faced another problem [ minor ] with my Without Authentication Project, I couldn't access /laravel-websockets.
I decided to extend the WebSocketsServiceProvider and add :
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Gate;
use BeyondCode\LaravelWebsockets\WebSocketsServiceProvider;
use BeyondCode\LaravelWebSockets\Dashboard\Http\Controllers\AuthenticateDashboard;
use BeyondCode\LaravelWebSockets\Dashboard\Http\Controllers\DashboardApiController;
use BeyondCode\LaravelWebSockets\Dashboard\Http\Controllers\SendMessage;
use BeyondCode\LaravelWebSockets\Dashboard\Http\Controllers\ShowDashboard;
use BeyondCode\LaravelWebSockets\Dashboard\Http\Middleware\Authorize as AuthorizeDashboard;
use BeyondCode\LaravelWebSockets\Statistics\Http\Controllers\WebSocketStatisticsEntriesController;
class WebSocketServiceProvider extends WebSocketsServiceProvider
{
protected function registerRoutes()
{
Route::prefix(config('websockets.path'))->group(function ()
{
Route::get('/', ShowDashboard::class);
Route::get('/api/{appId}/statistics', [DashboardApiController::class, 'getStatistics']);
Route::post('auth', AuthenticateDashboard::class);
Route::post('event', SendMessage::class);
Route::post('statistics', [WebSocketStatisticsEntriesController::class, 'store']);
});
return $this;
}
protected function registerDashboardGate()
{
Gate::define('viewWebSocketsDashboard', function ($user = null)
{
return true;
});
}
}
config.app.php
App\Providers\WebSocketServiceProvider::class
But, of course, error appears when trying to connect to port 6002:
WebSocket connection to 'ws://my-domain:6001/app/my-app-key?protocol=7&client=js&version=4.3.1&flash=false' failed: Error in connection establishment: net::ERR_CONNECTION_TIMED_OUT
And I can't access statistics:
GET http://my-domain/laravel-websockets/api/my-app-id/statistics 500 (Internal Server Error)
I have an issue with Websockets and my actuel websocket test project. No problems with my local project. But when it comes to deploy on my Laravel Forge Server I get the :
app.js:41145 WebSocket connection to 'wss://my-domain:6002/app/my-app-key?protocol=7&client=js&version=7.0.0&flash=false' failed: Error in connection establishment: net::ERR_SSL_PROTOCOL_ERROR
I think it is important to indicate that I do not have implemented a Authentication on my project.
My configuration is as follows :
broadcasting.php
websockets.php
bootstrap.js
I of course followed the tutorial from Alex Bouma and added port 6002 in the Network Tab
WS | 6002 | Allow | Any
And implemented to daemons in the Deamon Tab
Nginx config file :
I faced another problem [ minor ] with my Without Authentication Project, I couldn't access /laravel-websockets. I decided to extend the
WebSocketsServiceProvider
and add :config.app.php
App\Providers\WebSocketServiceProvider::class
But, of course, error appears when trying to connect to port 6002:
WebSocket connection to 'ws://my-domain:6001/app/my-app-key?protocol=7&client=js&version=4.3.1&flash=false' failed: Error in connection establishment: net::ERR_CONNECTION_TIMED_OUT
And I can't access statistics:
GET http://my-domain/laravel-websockets/api/my-app-id/statistics 500 (Internal Server Error)