Hello,
im trying to make Websocket work with my Dev Docker setup, but there is still some problem i cant figure out.
This is my docker-compose.yaml i start the Websocket Server in its own container its upp and running
websocket:
image: docker-registry.company.com/cx_dev_app:latest
working_dir: /www/
volumes:
# Projects
- ../vme/.:/www/vme
- ./app/cron.d/.:/etc/my.cron.d
- ./app/startup.sh:/startup.sh
- ./app/websocket.sh:/websocket.sh
command: ["sh", "-c", "php /www/vme/artisan websockets:serve --host=0.0.0.0"]
ports:
- "6001:6001"
expose:
- "6001"
environment:
depends_on:
- app
networks:
app_net:
ipv4_address: xxx.29.0.88
The Server is up and runing:
websocket_1 | Starting the WebSocket server on port 6001...
broadcasting.php:
'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'),
'host' => 'websocket',
'port' => 6001,
'encrypted' => true,
'scheme' => 'http'
],
],
and the bootstrap.js:
window.Echo = new Echo({
broadcaster: 'pusher',
key: 'vme-key',
wsHost: window.location.hostname,
wsPort: 6001,
disableStats: true,
});
When i refresh my page i get following error:

Sadly could not find anything similar to this Issue.
The same issue here, with docker.
I have those errors:
Have you handle with it?
If i remember correctly we started the websocket on --host=0.0.0.0 also exposed the 6001 port in our docker-composer.yml file.
The same issue here, with docker
How can I run laravel-websocket server with docekr
Hi, we handle it.
First, you have to setup port for this 6001 in docker.
Second, run server inside of docker bash.
You don't need any additional libraries ect.
If it's possible, share the errors with me - meaby i will help :)
@MWL91
Hi, thank you
can you share me your docker-compose.yml for websocket
my error same with you
thanks
Have you port 6001 setup on docker?
Wiadomość napisana przez edisonchenz notifications@github.com w dniu 14.02.2019, o godz. 01:49:
@MWL91
Hi, thank you
can you share me your docker-compose.yml for websocket
my error same with youWebSocket connection to 'ws://localhost:6001/app/anyKey?protocol=7&client=js&version=4.3.1&flash=false' failed: Error in connection establishment: net::ERR_SOCKET_NOT_CONNECTED
pusher.min.js:8 WebSocket connection to 'ws://localhost:6001/app/anyKey?protocol=7&client=js&version=4.3.1&flash=false' failed: Connection closed before receiving a handshake response
thanks—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
it would be amazing if this package comes with a docker container out of the box. And is maintained by the owners. Are there any plans for this? @freekmurze @mpociot
I can share my Dockerfile.
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 \
&& \
docker-php-ext-install \
pcntl \
mbstring \
pdo \
pdo_mysql \
tokenizer \
xml \
sockets \
gmp \
bcmath \
intl \
&& \
# Libevent
pecl install event && \
# phpiredis
apk add --no-cache --virtual .build-deps \
hiredis-dev \
&& \
git clone https://github.com/francislavoie/phpiredis.git && \
( \
cd phpiredis && \
phpize && ./configure --enable-phpiredis && \
make && make install && \
docker-php-ext-enable phpiredis \
) && \
rm -rf phpiredis && \
# Cleanup
apk del .build-deps && \
rm -rf /var/cache/apk/* && \
mkdir -p /var/www
RUN groupmod -g 1000 www-data && \
usermod -u 1000 www-data
USER www-data
WORKDIR /var/www
EXPOSE 6001
CMD ["php", "artisan", "websockets:serve"]
You can probably strip out the phpiredis stuff, it's essentially a performance optimization when using Predis (which Laravel uses) but laravel-websockets doesn't use Predis, and https://github.com/beyondcode/laravel-websockets/pull/140 won't use Predis either because it uses the ReactPHP async Redis client instead. If you do end up needing it, I recommend configuring your config/database.php redis config with the following, which will make Predis use the phpiredis extension for better performance.
'options' => [
'connections' => [
'tcp' => 'Predis\Connection\PhpiredisStreamConnection',
'unix' => 'Predis\Connection\PhpiredisSocketConnection',
],
],
I made a fork because the phpiredis repo is inactive and is broken... I pulled in fixes from a few different pending PRs into my fork to make it work.
But anyways - all that is irrelevant, that Dockerfile should just work as-is. laravel-websockets has very few requirements to work well.
@francislavoie can you share the part of laravel websockets in docker-compose file, please.
Is it better to use it in a separate container?
I have configured the package in the same container of laravel app, first, the graph in the dashboard wasn't visible, I solved it by making perform_dns_lookup to true, but when I fire an event from tineker I don't see the trace of it in the dashboard.
i've tried several solutions like using the address IP of the container (or the name) besides using localhost (or 127.0.0.1)!
Sounds like you're running into https://github.com/beyondcode/laravel-websockets/pull/115
I prefer to run it in a separate container. I have these: caddy, websockets, php-fpm, horizon, db, redis and workspace (for general use CLI, artisan). Separation of concerns.
There's really nothing special to show in my docker-compose file, I just point to the Dockerfile to build, and share a volume for the code between containers.
@francislavoie I'm still getting the same issue, regardless that websockets container runs correctly, I get no traces in the dashboard when firing the event from tinker.
this is my dockerfile of websockets container:
FROM php:7.3.3-alpine
# FROM php:7.2-fpm
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"]
this is websockets service in docker-compoe
ssms-sockets:
build:
context: ./docker/websockets
container_name: ssms-sockets
volumes:
- .:/var/www/html
ports:
- 6001:6001
networks:
backend:
aliases:
- ssms-sockets
in the app container i'm exposing port 6001, and i'm setting the host to the name of the container:
PUSHER_APP_HOST=ssms-app
@francislavoie can you share the part of laravel websockets in docker-compose file, please.
Is it better to use it in a separate container?
I have configured the package in the same container of laravel app, first, the graph in the dashboard wasn't visible, I solved it by makingperform_dns_lookupto _true_, but when I fire an event from tineker I don't see the trace of it in the dashboard.
i've tried several solutions like using the address IP of the container (or the name) besides using localhost (or 127.0.0.1)!
I'm having this same problem. Were you able to resolve this? I'll like to know how you did, if you were. Thanks
greetings, I walk by here and I see that the last post, still persisted the problem, some will have solved it, I am in the same diatrive
I've started to use ratchet that allows to in-websocket interactions. The issue in my case was mismatch with events. Ratchet works also much faster.
Most helpful comment
Hi, we handle it.
First, you have to setup port for this 6001 in docker.
Second, run server inside of docker bash.
You don't need any additional libraries ect.
If it's possible, share the errors with me - meaby i will help :)