@TANK_IST

Как запустить websocket на https?

Использую Ratchet на сайте Symfony.
JS
websocket = new WebSocket('ws://'+location.hostname+':8888');

PHP
<?php
namespace OwrBundle\Command;

use Symfony\Component\Console\{Command\Command, Input\InputInterface, Output\OutputInterface};
use OwrBundle\Sockets\WebSocket;
use Ratchet\{App, Session\SessionProvider};
use Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcachedSessionHandler;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;

class SocketCommand extends ContainerAwareCommand
{
    protected function configure()
    {
        $this->setName('sockets:start');
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $output->writeln([ 'Socket start' ]);

        $memcached = new \Memcached();
        $memcached->addServer('localhost', 11211);

        $session = new SessionProvider(
            new WebSocket($this->getContainer()),
            new MemcachedSessionHandler($memcached)
        );

        var_dump($this->getContainer()->getParameter('host'));

        $server = new App($this->getContainer()->getParameter('host'), 8888, '0.0.0.0');
        $server->route('/', $session);
        $server->run();
    }
}

После перехода на https он уже не работает.
Как это поправить?
  • Вопрос задан
  • 812 просмотров
Пригласить эксперта
Ответы на вопрос 1
@lem_prod
websocket = new WebSocket('wss://'+location.hostname+':8888');
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы