Answer the question
In order to leave comments, you need to log in
Why doesn't Workerman work for wss connection?
There is a websocket daemon in PHP 7.0 (implemented in Workerman ). Piece of code:
$worker = new Worker('websocket://my-domain.com:8084', [
'ssl' => [
'local_cert' => '/etc/letsencrypt/live/my-domain.com/cert.pem',
'local_pk' => '/etc/letsencrypt/live/my-domain.com/privkey.pem',
'verify_peer' => false,
]
]);
$worker->transport = 'ssl';
$worker->count = 1;
$worker->onConnect = function ($connection) { ... }
Error: stream_socket_enable_crypto(): SSL_R_NO_SHARED_CIPHER: no suitable shared cipher could be used. This could be because the server is missing an SSL certificate (local_cert context option)
Answer the question
In order to leave comments, you need to log in
In general, I suffered and suffered, which I just didn’t try :)) In the end, everything turned out to be very simple: the problem is that the certificates are located in /etc/letsencrypt/live/ and, in fact, workerman has no access to them, the solution is to make links to certificates and put these links next to the startup script.
example:
sudo cp -l /etc/letsencrypt/live/my-domain.com/fullchain.pem /var/www/yoursite/fullchain.pem
sudo cp -l /etc/letsencrypt/live/my-domain.com/privkey .pem /var/www/yoursite/privkey.pem
and then connect
$context = array(
'ssl' => array(
'local_cert' => __DIR__.'/fullchain.pem',
'local_pk' => __DIR__.'/privkey.pem',
'verify_peer' => false,
)
);
// Create a Websocket server
$ws_worker = new Worker("websocket://0.0.0.0:8084", $context);//0.0.0.0 - значит принимать соединения от любого ip
$ws_worker->transport = 'ssl';
It is written in black and white that this error is probably due to the fact that it cannot find the certificate from the local_cert property on the disk.
Check if the paths to the certificates
are correct. If everything is correct, then look towards the crypto_type.
One that is not available on the server can be selected.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question