2016-03-19 18 views
2

私は古くからHerokuを使用していないので、ちょっと錆びます。 ラチェットIOServerを実行する小さなPHPアプリケーションを作成しました。ポート5000でリッスンします。heroku localを実行してtelnet localhost 5000と接続すると、すべて動作するようです。私はPHPプロセスを実行して接続を受け付けるいくつかの方法を試しました。WebSocketはローカルではありませんが、Heroku上では動作しません - PHPアプリケーション

私のProcfileは次のようになります。

web: php bin/console bot:start 

私はそれが動作しませんHerokuのにサーバーを展開するときheroku local

Downloading forego-0.16.1 to /Users/roje/.heroku... done 
forego | starting web.1 on port 8080 
web.1 | It works! 
web.1 | New connection! (97) 
web.1 | Connection 97 sending message "sdfdfs" 

実行。 は、私はポート5000上のボックスにtelnetで接続しようとすると、私は

telnet myapplication.herokuapp.com 5000 
Trying 46.137.127.234... 
telnet: connect to address 46.137.127.234: Connection refused 
telnet: Unable to connect to remote host 

を取得したログは、もう少し情報が表示されます。

2016-03-19T16:08:27.258081+00:00 heroku[web.1]: State changed from crashed to starting 
2016-03-19T16:08:29.754688+00:00 heroku[web.1]: Starting process with command `php bin/console bot:start` 
2016-03-19T16:08:31.659074+00:00 app[web.1]: It works! 
2016-03-19T16:09:29.999903+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch 
2016-03-19T16:09:29.999903+00:00 heroku[web.1]: Stopping process with SIGKILL 
2016-03-19T16:09:30.638659+00:00 heroku[web.1]: Process exited with status 137 
2016-03-19T16:09:30.660710+00:00 heroku[web.1]: State changed from starting to crashed 
2016-03-19T16:18:51.610894+00:00 heroku[web.1]: State changed from crashed to starting 
2016-03-19T16:18:55.208396+00:00 heroku[web.1]: Starting process with command `php bin/console bot:start` 
2016-03-19T16:18:56.648708+00:00 app[web.1]: It works! 
2016-03-19T16:19:55.569256+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch 
2016-03-19T16:19:55.569256+00:00 heroku[web.1]: Stopping process with SIGKILL 
2016-03-19T16:19:56.252235+00:00 heroku[web.1]: Process exited with status 137 
2016-03-19T16:19:56.264205+00:00 heroku[web.1]: State changed from starting to crashed 

お勧めはありますか?私は動的ポートHeroku + node.js error (Web process failed to bind to $PORT within 60 seconds of launch)

を割り当てるHerokuの約一部を読み取る

EDIT#1

私の代わりに、そのポートをリッスンしようとしたが、私はまだを介して接続傾けます。 telnet。面白いログがありますが。多分あなたの何人かがIPアドレスを試していますか?

2016-03-19T16:38:35.577130+00:00 app[web.1]: It works! 
2016-03-19T16:38:35.827466+00:00 app[web.1]: New connection! (97) 
2016-03-19T16:38:35.827531+00:00 app[web.1]: Connection 97 has disconnected 
2016-03-19T16:38:35.832097+00:00 app[web.1]: New connection! (107) 
2016-03-19T16:38:35.832160+00:00 app[web.1]: Connection 107 has disconnected 
2016-03-19T16:38:49.891455+00:00 app[web.1]: New connection! (108) 
2016-03-19T16:38:49.891506+00:00 app[web.1]: Connection 108 has disconnected 
2016-03-19T16:40:54.694321+00:00 app[web.1]: New connection! (109) 
2016-03-19T16:40:54.694368+00:00 app[web.1]: Connection 109 has disconnected 

私はまだ同じエラーが発生します。

Trying 176.34.255.126... 
telnet: connect to address 176.34.255.126: Connection refused 
telnet: Unable to connect to remote host 
+0

私は、Herokuが外部から80または443以外のものに接続できるとは思いません。 http://stackoverflow.com/questions/8107748/can-a-heroku-app-use-different-multiple-portsを参照してください。ポート5000はインスタンス内にありますが、Herokuのルータは外部にルーティングしません。 – ceejayoz

+0

環境変数でHerokuが動的に定義したポートでIOServerを起動しようとしました。この場合、ポートは '40220 'として割り当てられました。まだ運がない。 –

答えて

-2

ファイアウォールとポートを確認しましたか?

+0

Herokuは、プラットフォームとしてのサービスプロバイダーです。ファイアウォールとポート設定にアクセスすることはできません。 – ceejayoz

0

私はウェブソケットの前でプロキシとしてnginxを使ってこれを管理することができました。

Procfile:

web: private/bin/start_socket vendor/bin/heroku-php-nginx -C nginx_app.conf 

start_socket:

php private/bin/start_socket.php & 
exec "[email protected]" 

start_socket.php:

<?php 
require_once(dirname(dirname(__DIR__)) . '/vendor/autoload.php'); 
require_once(__DIR__ . '/socket/socket.php'); 

use Ratchet\Server\IoServer; 
use Ratchet\Http\HttpServer; 
use Ratchet\WebSocket\WsServer; 

$server = IoServer::factory(
    new HttpServer(
     new WsServer(
      new Socket() 
     ) 
    ), 
    8085 
); 
$server->run(); 

nginx.conf:

location /wss { 
    proxy_pass http://localhost:8085; 
    proxy_http_version 1.1; 
    proxy_set_header Upgrade $http_upgrade; 
    proxy_set_header Connection "upgrade"; 
} 

これでソケットにアクセスできます:https://myapp.com/wss?mydata=test。これは、各dynoが独自のwebsocketサーバーを実行するという事実を回避するものではありませんが、それは完全に別個の質問です。

関連する問題