2017-04-25 1 views
0

내 웹 소켓 파일 :래칫 PHP 웹 소켓 지속적 우분투 16.04

<?php 
require __DIR__ . '/../../../vendor/autoload.php'; 

use Ratchet\MessageComponentInterface; 
use Ratchet\ConnectionInterface; 

require 'chat.php'; 

// Run the server application through the WebSocket protocol on port 8080 
$app = new Ratchet\App("localhost", 8080, '0.0.0.0', $loop); 
$app->route('/chat', new Chat, array('*')); 

$app->run(); 

나는 셋업 내 웹 소켓이 설명서 다음 : 그것은 php socket.php를 사용하여 작동 로컬 https://blog.samuel.ninja/the-tutorial-for-php-websockets-that-i-wish-had-existed/

을 (창 10에 XAMPP 테스트) .

WebSocket connection to 'ws://localhost:8080/chat?id=NDY=&group=43,60' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED 

PS : 내 가상 컴퓨터에 배포 할 때 는 (16.04를 우분투)이 오류가 나는 또한 대신에 서비스를 시작해야 php /var/www/path-to-websocket/socket.php

사용하여 웹 소켓을 시작하려고했다 명령 줄은 있지만 설명 된 방법이 작동하지 않습니다.

답변

0

localhost 대신 SERVERNAME을 사용해보십시오.

Run your website and WebSocket server on the same machine using port 8080 for WebSockets and take the chance client proxies won't block traffic 
Run your WebSocket server on its own server on port 80 under a subdomain (sock.example.com) 
Put a reverse proxy (HAProxy or Varnish) in front of your webserver and WebSocket server 

소스 : http://socketo.me/docs/deploy

PHP의 RATCHET에서