2016-04-28 23 views
0

ラチェットオーバーSSLの問題を調査していて、proxy.loadとproxy_wstunnel.loadを有効にしてApache2サーバーの設定を取得しようとしています。ラチェットWebsocket Apache2 SSLがPHP websocketに接続できません

/etc/apache2/mods-enabled: 
    proxy.conf -> ../mods-available/proxy.conf 
    proxy.load -> ../mods-available/proxy.load 
    proxy_wstunnel.load -> ../mods-available/proxy_wstunnel.load 

は、私は私のapache2.confの最後に次の行を追加しました:

ProxyPass /wss2/ ws://domain.com:8080

PHPソケットserver.phpというファイル:

use Ratchet\Server\IoServer; 
use Ratchet\Http\HttpServer; 
use Ratchet\WebSocket\WsServer; 
use Websocket\SocketControl; 
use Ratchet\Session\SessionProvider; 
use Symfony\Component\HttpFoundation\Session\Storage\Handler; 

    require dirname(__DIR__) . '/vendor/autoload.php'; 

    $memcache = new Memcache; 
    $memcache->connect('localhost', 11211); 

    $session = new SessionProvider(
     new SocketControl, 
     new Handler\MemcacheSessionHandler($memcache) 
    ); 

    $server = IoServer::factory(
     new HttpServer(
      new WsServer(
       $session 
      ) 
     ), 
     8080 
    ); 

    $server->run(); 

関連をソケットサーバーへの接続を試みるJSコード:

var websocket = { 
    wsUri:"wss://domain.com/wss2/NNN", 
    socket:null, 
    cryptKey:null, 
    init:function(){ 
     try { 
      if (typeof MozWebSocket == "function") 
       WebSocket = MozWebSocket; 
      if (websocket.socket && websocket.socket.readyState == 1) 
       websocket.socket.close(); 

      websocket.socket = new WebSocket(websocket.wsUri); 
      websocket.socket.onopen = websocket.onopen.bind(); 
      websocket.socket.onclose = websocket.onclose.bind(); 
      websocket.socket.onmessage = websocket.onmessage.bind(); 
      websocket.socket.onerror = websocket.onerror.bind(); 

     } catch (exception) { 
      console.log("ERROR: " + exception); 
     } 
    }, 

接続しようとしたとき、私は受信エラー:

WebSocket connection to 'wss://domain.com/wss2/NNN' failed: Error during WebSocket handshake: Unexpected response code: 502

答えて

0

問題は、使用しているURLにあります。

wsUri:"wss://domain.com/wss2/NNN", 

あなたは試みることができる:

wsUri:"wss://domain.com/wss2", 

ので、あなたの設定でそのURLにリンクします

関連する問題