.env
& boradcasting.php
like so PUSHER_APP_ID=123456789
PUSHER_APP_KEY=AZERTYUIOP
PUSHER_APP_SECRET=QSDFGHJKLMWXCVBN
PUSHER_APP_CLUSTER=mt1
PUSHER_APP_HOST=localhost # or 127.0.0.1
'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' => env('PUSHER_APP_HOST'),
'port' => 6001,
'scheme' => 'http',
],
],
6001
in Dockerfile
of project container.php artisan websockets:serve
from within the container.WebSocketsTestEvent
event from a tinker session
class WebSocketsTestEvent implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
protected $message;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($message)
{
$this->message = $message;
}
/**
* Get the channels the event should broadcast on.
*
* @return \Illuminate\Broadcasting\Channel|array
*/
public function broadcastOn()
{
return new PrivateChannel('test');
}
}
.env
like so :PUSHER_APP_ID=123456789
PUSHER_APP_KEY=AZERTYUIOP
PUSHER_APP_SECRET=QSDFGHJKLMWXCVBN
PUSHER_APP_CLUSTER=mt1
PUSHER_APP_HOST=ssms-app # or the @IP of the conatiner
websockets
container like so:FROM php:7.3.3-alpine
RUN apk add --no-cache \
wget \
curl \
# git \
shadow \
build-base \
autoconf \
# hiredis \
libxml2-dev \
zlib-dev \
libevent \
libevent-dev \
openssl-dev \
gmp-dev \
icu-dev
RUN docker-php-ext-install \
pcntl \
mbstring \
pdo \
pdo_mysql \
tokenizer \
xml \
sockets \
gmp \
bcmath \
intl
# Libevent
RUN pecl install event
RUN apk update
# Cleanup
# apk del .build-deps && \
RUN rm -rf /var/cache/apk/* && \
rm -rf /tmp/*
RUN mkdir -p /var/www
RUN groupmod -g 1000 www-data && \
usermod -u 1000 www-data
USER www-data
WORKDIR /var/www/html
EXPOSE 6001
CMD ["php", "artisan", "websockets:serve"]
docker-compose.yaml
like so:
ssms-app:
build:
context: ./docker/app
args:
uid: ${UID}
container_name: ssms-app
environment:
- APACHE_RUN_USER=#${UID}
- APACHE_RUN_GROUP=#${UID}
volumes:
- .:/var/www/html
ports:
- ${HOST_PORT}:80
# - 6001:6001
links:
- ssms-redis
- ssms-sockets
networks:
backend:
aliases:
- ssms-app
ssms-sockets:
build:
context: ./docker/websockets
container_name: ssms-sockets
volumes:
- .:/var/www/html
ports:
- 6001:6001
networks:
backend:
aliases:
- ssms-sockets
in both cases i get the same issues:
the graph in the dashboard, after visiting http://localhost:8080/laravel-websockets
is not displayed.
Note: this is fixed by setting
'perform_dns_lookup' => true
inconfig/websockets.php
.
no traces indicating that the event is broadcasted by the package in the dashboard.
At last, Any solutions? I'm stuck for about 3 days
maybe try to edit the .env file to use host.docker.internal
like so
PUSHER_APP_ID=123456789
PUSHER_APP_KEY=AZERTYUIOP
PUSHER_APP_SECRET=QSDFGHJKLMWXCVBN
PUSHER_APP_CLUSTER=mt1
PUSHER_APP_HOST=host.docker.internal
after than run php artisan config:cache
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With