0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

WebSocket connection to 'ws://localhost:8080/app/***?protocol=7&client=js&version=8.4.0&flash=false' failed:

Last updated at Posted at 2025-02-14

概要

Laravel Reverbを使おうと思い、開発環境を立ち上げたのですが、ブラウザのコンソールに上記タイトルのエラーが出るので、その時の対応をメモしておきます。

前提

・開発環境での話です。Docker+Sail(Ubuntu)
・Laravelバージョン:11

解決策

・docker-compose.ymlのports設定のところでReverbのポートを追加しました。

config/livewire.php(抜粋)
services:
    laravel.test:
        build:
            context: './vendor/laravel/sail/runtimes/8.4'
            dockerfile: Dockerfile
            args:
                WWWGROUP: '${WWWGROUP}'
        image: 'sail-8.4/app'
        extra_hosts:
            - 'host.docker.internal:host-gateway'
        ports:
            - '${APP_PORT:-80}:80'
            - '${VITE_PORT:-5173}:${VITE_PORT:-5173}'
            - 8080:8080      # << ここを追加
        environment:
         ・
         ・
         ・

余談

REVERBをインストールしたときに設定されたREVERB_APP_KEY変数の値をデタラメな値に変えて試したんですけど、なぜか問題なく動いている。何か設定を間違えているのかな?と思いましたが、.envに設定した値とは違う値を使ってws://***にアクセスされた場合、アクセスを拒否するという感じですね。

コンソールから、以下のコマンドを使って、.envで設定された値と違う値でアクセスしたところ、ちゃんと拒否されました。

コンソールでの実行コマンド
wscat -c 'ws://IPアドレス/app/REVERB_APP_KEYの値?protocol=7&client=js&version=8.4.0&flash=false'
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?