Reputation: 767
I have the Laravel project with websocket. I cloned the project on server with cPanel. Now I can access the running Laravel project through a sub domain like https://app.example.com. But I can not able to use the websocket with that domain name, because time out.
The websocket which I using is wss
. I used the following command to run the websocket : php artisan websocketsecure:init
. The command is running successfully, but I can't able to use. I tried the following address wss://app.example.com:8090
How can I access the secure websocket in the Laravel project?
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Ratchet\Server\IoServer;
use Ratchet\Http\HttpServer;
use Ratchet\WebSocket\WsServer;
use React\EventLoop\Factory;
use React\Socket\SecureServer;
use React\Socket\Server;
use App\Http\Controllers\WebSocketController;
class WebSocketSecureServer extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'websocketsecure:init';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$loop = Factory::create();
$webSock = new SecureServer(
new Server('0.0.0.0:8090', $loop),
$loop,
array(
'local_cert' => '/apache/conf/ssl.crt/server.crt', // path to your cert
'local_pk' => '/apache/conf/ssl.key/server.key', // path to your server private key
'allow_self_signed' => TRUE, // Allow self signed certs (should be false in production)
'verify_peer' => FALSE
)
);
// Ratchet magic
$webServer = new IoServer(
new HttpServer(
new WsServer(
new WebSocketController()
)
),
$webSock
);
$loop->run();
}
}
Upvotes: 1
Views: 2559
Reputation: 9381
Well to run websockets you have 2 requirements basically:
The last part is probably where your problem lies.
Upvotes: 1