4

I try to connect from php to server by using websockets. This is my code

$opts = [
    'ssl' => [
        'cafile' => 'core/certs/root.pem',
        'local_cert' => 'core/certs/client.pem',
        'local_pk' => 'core/certs/client_key.pem'
    ]
];
$content = stream_context_create($opts, $opts);

$socket = stream_socket_server(
    "wss://$host",
    $errno,
    $errstr,
    STREAM_SERVER_BIND|STREAM_SERVER_LISTEN,
    $content
);

After running script I got error:

Unable to find the socket transport "wss" - did you forget to enable it when you configured PHP? (0)

How to enable socket transport "wss" in apache?

mdBender
  • 369
  • 2
  • 8
  • Unfortunately no. As I found out PHP does not support web socket transport wss. If you will find out that I am wrong, please, get me know – mdBender Jan 27 '23 at 09:09
  • There are php libraries that can do it though, so surely it must be possible somehow. I ended up grudgingly using Textalk/websocket-php after wasting a lot of time trying to find a compact native solution. – Doskii Feb 07 '23 at 07:45

0 Answers0