1

Herokuで最初のdjangoアプリを実行しようとしています.アプリを正常にデプロイでき、Webソケット以外のすべてが機能します. ローカルでメモリ チャネルを使用したところ、すべてが機能しました。メモリ チャネルと redis の両方で heroku を試しましたが、どちらも機能しません。さまざまな構成を試しましたが、有効な解決策を見つけることができませんでした。また、heroku のログから、何が問題なのかわかりません。

ブラウザで表示されるエラー:

join_game.js:222 WebSocket connection to 'wss://battleships-war.herokuapp.com/game/20' failed: Error during WebSocket handshake: Unexpected response code: 404

Javascript クライアント コード:

[ws と wss プレフィックスを試しましたが、どちらもクラッシュしました]

var ws = new WebSocket((window.location.protocol == 'http') ? 'ws://' : 'wss://' +  window.location.host + '/game/' + gameId);

settings.py の redis 構成

 CHANNEL_LAYERS = {
     "default": {
         "BACKEND": "asgi_redis.RedisChannelLayer",
         "CONFIG": {
             "hosts": [('ec2-34-254-133-4.eu-west-1.compute.amazonaws.com', 26849)],
        },
         'ROUTING': 'battleships.routing.channel_routing',
    }, }

ローカルで機能するメモリ構成のオプション:

CHANNEL_LAYERS = {
    'default': {
        'BACKEND': 'asgiref.inmemory.ChannelLayer',
        'ROUTING': 'battleships.routing.channel_routing',
    },
}

heroku からの redis 資格情報:

  • ホスト: ec2-34-254-133-4.eu-west-1.compute.amazonaws.com
  • ユーザー
  • ポート 26849
  • パスワード
  • URI: redis://h:p69877187246d4f0b36a94488814ee0b372234a2e943a61df0cdc84e4f85f35f2@ec2-34-254-133-4.eu-west-1.compute.amazonaws.com:26849

プロセスファイル:

web: gunicorn battleships.wsgi --preload

ヒロクのログ:

2019-01-14T21:06:52.847189+00:00 heroku[web.1]: 2019-01-14T21:07:00.911326+00:00 heroku[web.1]: コマンドでプロセスを開始するまでの状態が変更されましたgunicorn battleships.wsgi --preload 2019-01-14T21:07:04.629926+00:00 heroku[web.1]: 状態が開始からアップに変更されました 2019-01-14T21:07:06.453341+00:00 heroku[web.1]: プロセスが状態で終了しました0 2019-01-14T21:07:51.531270+00:00 heroku[ルーター]: at=info method=GET path="/new_game/" host=battleships-war.herokuapp.com request_id=45707e08-cfd9-458c-8ce4 -0f423acfb632 fwd="80.49.199.124" dyno=web.1 connect=0ms service=374ms status=200 bytes=1307 protocol=http 2019-01-14T21:07:53.241606+00:00 heroku[router]: at=info method=GET path="/new_game/" host=battleships-war.herokuapp.com request_id=a77411fc-2ab6-4be7-b4c9-e86d9440c3e1 fwd="80.49.199.124" dyno=web.1 connect=0ms service=163ms status= 200 バイト = 1307 プロトコル = http 2019-01-14T21:07:57.454852+00:00 heroku[ルーター]: at=info method=POST path="/new_game/"host=battleships-war.herokuapp.com request_id=76aab54e-4508-4485-90de-e66e7bb4715b fwd="80.49.199.124" dyno=web.1 接続=0ms サービス=31ms ステータス=200 バイト=290 プロトコル=http 2019-01 -14T21:08:01.604730+00:00 heroku[router]: at=info method=GET path="/game/22/dfgdfgdfgdf" host=battleships-war.herokuapp.com request_id=d4c9a​​31a-0dc6-436a-b35b- 054e94770a5e fwd="80.49.199.124" dyno=web.1 connect=0ms service=30ms status=200 bytes=1310 protocol=http 2019-01-14T21:08:02.002519+00:00 heroku[router]: at=info メソッド=GET path="/game/22/dfgdfgdfgdf/join" host=battleships-war.herokuapp.com request_id=3c682a1a-f203-493a-853d-4a4ff9cccaf8 fwd="80.49.199.124" dyno=web.1 connect=0ms サービス=267ms ステータス=500 バイト=149564 プロトコル=http 2019-01-14T21:07:03+00:00 app[heroku-redis]:source=REDIS addon=redis-octagonal-92972 sample#active-connections=1 sample#load-avg-1m=0.09 sample#load-avg-5m=0.115 sample#load-avg-15m=0.125 sample#read-iops= 0 sample#write-iops=0 sample#memory-total=15664336kB sample#memory-free=11855124kB sample#memory-cached=1580208kB sample#memory-redis=278200bytes sample#hit-rate=0 sample#evicted-keys=0 2019-01-14T21:08:07.295235+00:00 heroku[ルーター]: at=info method=GET path="/game/22/dfgdfgdfgdf" host=battleships-war.herokuapp.com request_id=789356b5-acb3-48e7 -9dd1-be5250a7445d fwd="80.49.199.124" dyno=web.1 接続=0ms サービス=25ms ステータス=200 バイト=1310 プロトコル=http125 sample#read-iops=0 sample#write-iops=0 sample#memory-total=15664336kB sample#memory-free=11855124kB sample#memory-cached=1580208kB sample#memory-redis=278200bytes sample#hit-rate=0 sample#evicted-keys=0 2019-01-14T21:08:07.295235+00:00 heroku[ルーター]: at=info method=GET path="/game/22/dfgdfgdfgdf" host=battleships-war.herokuapp.com request_id=789356b5-acb3-48e7-9dd1-be5250a7445d fwd="80.49.199.124" dyno=web.1 connect=0ms サービス=25ms ステータス=200 バイト=1310 プロトコル=http125 sample#read-iops=0 sample#write-iops=0 sample#memory-total=15664336kB sample#memory-free=11855124kB sample#memory-cached=1580208kB sample#memory-redis=278200bytes sample#hit-rate=0 sample#evicted-keys=0 2019-01-14T21:08:07.295235+00:00 heroku[ルーター]: at=info method=GET path="/game/22/dfgdfgdfgdf" host=battleships-war.herokuapp.com request_id=789356b5-acb3-48e7-9dd1-be5250a7445d fwd="80.49.199.124" dyno=web.1 connect=0ms サービス=25ms ステータス=200 バイト=1310 プロトコル=httpcom request_id=789356b5-acb3-48e7-9dd1-be5250a7445d fwd="80.49.199.124" dyno=web.1 connect=0ms サービス=25ms ステータス=200 バイト=1310 プロトコル=httpcom request_id=789356b5-acb3-48e7-9dd1-be5250a7445d fwd="80.49.199.124" dyno=web.1 connect=0ms サービス=25ms ステータス=200 バイト=1310 プロトコル=http

誰かがそれを手伝ったり、別のアプローチを提案したりできますか?

4

1 に答える 1