我有一个运行 Laravel 的 Docker 环境,我想让 laravel-websockets 工作。
当我访问这里时:
http://localhost:8000/laravel-websockets
我收到以下错误:
开发工具为我提供了以下信息:
WebSocket connection to 'ws://localhost:6001/app/local?protocol=7&client=js&version=4.3.1&flash=false' failed: Connection closed before receiving a handshake response
我有以下 docker-compose.yaml:
version: "3.8"
services:
server:
build:
context: .
dockerfile: dockerfiles/nginx.dockerfile
ports:
- "8000:80"
- "6001:6001"
volumes:
- ./src:/var/www/html
- ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf:ro
depends_on:
- app
app:
build:
context: .
dockerfile: dockerfiles/php.dockerfile
volumes:
- ./src:/var/www/html:delegated
我的 php.dockerfile 看起来像这样:
FROM php:8.0-fpm-alpine
USER root
WORKDIR /var/www/html
COPY src .
RUN apk --no-cache add libxml2-dev
RUN docker-php-ext-install soap
RUN docker-php-ext-install pdo pdo_mysql
RUN echo 'max_execution_time = 120' >> /usr/local/etc/php/conf.d/docker-php-maxexectime.ini;
EXPOSE 6001
我绝不是专家,所以我可能会遗漏一些明显的东西。任何帮助表示赞赏。
=============
编辑:附加信息
它在本地设置:
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'cluster' => env('PUSHER_APP_CLUSTER'),
'encrypted' => false,
'host' => '127.0.0.1',
'port' => 6001,
'scheme' => 'http'
],
],
我跑了:
php artisan websockets:serve