I'm struggling with a setup for Laravel echo server on Docker (laradock). I followed up this tutorial. I setup a new laravel project under docker, and setup host to be testing.localhost. Connection with Redis works fine, echo server works fine and even listen for messages:
L A R A V E L E C H O S E R V E R
version 1.6.2
⚠ Starting server in DEV mode...
✔ Running at localhost on port 6001
✔ Channels are ready.
✔ Listening for http events...
✔ Listening for redis events...
Server ready!
Channel: user-channel
Event: UserEvent
My laravel-echo-server.json contains this:
{
"authHost": "localhost",
"authEndpoint": "/broadcasting/auth",
"clients": [],
"database": "redis",
"databaseConfig": {
"redis": {
"port": "6379",
"host": "redis"
}
},
"devMode": true,
"host": null,
"port": "6001",
"protocol": "http",
"socketio": {},
"sslCertPath": "",
"sslKeyPath": ""
}
On client app (Angular application), I tried a several combination:
// const config: SocketIoConfig = { url: '10.0.75.1:6001', options: {} }; - docker IP address
// const config: SocketIoConfig = { url: '192.168.1.7:6001', options: {} }; - my IP address
// const config: SocketIoConfig = { url: 'localhost:6001', options: {} };
// const config: SocketIoConfig = { url: '127.0.0.1:6001', options: {} };
But I always get a message in console
/socket.io/?EIO=4&transport=polling&t=Nf9A_rY net::ERR_CONNECTION_REFUSED
Does anyone know how to solve this problem?
Add to host laravel echo 0.0.0.0
Related
i'm using Redis, with socket.io, laravel-echo-server and VUe.
In my local machine it's working just fine but the only problem when i uploaded and made the configuration in the server is that laravel-echo-server is not even trying to authenticate nor sending an error, but works fine when i send or broadcast an event:
When i run an event, it reflects in Laravel-echo-server:PRODUCTION SERVER IMAGE
But it's not even trying to listen or authenticate, this is my listening code in Vue:
PRODUCTION SERVER IMAGE
mounted() {
//LARAVEL ECHO, SOCKET.IO, REDIS, etc
Echo.private(`messages.${this.user.id}`)
.listen('NewMessage', (e) => {
console.log("LLEGÓ MENSAJE NUEVO");
console.log(e);
this.handleIncoming(e.message);
});
But as i mentioned it does not show anything in Laravel-echo-server console.
With the same configuration this is how it looks in my local machine:
localhost IMAGE
As i said, it does not even try to authenticate or connect to the channel.
This is my laravel-echo-server.json:
PRODUCTION SERVER IMAGE
Am i missing something?
Why is it working with the events but no listening or at least try to listening to them?
Thank you so much!
EDIT 1:
This is part of my .env FILE
PRODUCTION SERVER IMAGE
BROADCAST_DRIVER=redis
CACHE_DRIVER=file
QUEUE_CONNECTION=redis
SESSION_DRIVER=file
SESSION_LIFETIME=120
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
This is part of my bootstrap.js
PRODUCTION SERVER IMAGE
import Echo from "laravel-echo"
window.io = require('socket.io-client');
window.Echo = new Echo({
broadcaster: 'socket.io',
host: '127.0.0.1:6001' //I CHANGED TO STATICALLY GO TO 127.0.0.1
});
And this is part of my config/database.php:
PRODUCTION SERVER IMAGE
In localhost it works just fine, using http:127.0.0.1:8000
and 127.0.0.1:6001 for laravel echo.
the problem is when i upload and configure in my AWS Lightsail, the domain is http://test1.erpnegocios.com and the route in the server is /var/www/html/test1
EDIT 2:
I've been reading posts that say that the host in bootstrap.js (socket.io) must be the same host in laravel-echo-server.json, that's why i'm using for both host: '127.0.0.1:6001' (as shown in the images) but the problem persists.
If i run sudo service redis-server stop, laravel-echo console stop working, so i assume that the connection is good, but i can't get clients connecting to channels, nor public or private
EDIT 3
Guys i changed my bootstrap.js and laravel-echo-server.json as follow:
bootstrap.js
window.Echo = new Echo({
broadcaster: 'socket.io',
host: window.location.hostname + ':6001' //El host de laravel-echo-server
});
laravel-echo-server.json
{
"authHost": "http://test1.erpnegocios.com:8000",
"authEndpoint": "/broadcasting/auth",
"clients": [],
"database": "redis",
"databaseConfig": {
"redis": {},
"sqlite": {
"databasePath": "/database/laravel-echo-server.sqlite"
}
},
"devMode": true,
"host": null,
"port": "6001",
"protocol": "http",
"socketio": {},
"secureOptions": 67108864,
"sslCertPath": "",
"sslKeyPath": "",
"sslCertChainPath": "",
"sslPassphrase": "",
"subscribers": {
"http": true,
"redis": true
},
"apiOriginAllow": {
"allowCors": false,
"allowOrigin": "",
"allowMethods": "",
"allowHeaders": ""
}
}
I also opened the port 8000 in my server, now running my laravel-echo-server console, i see:
Basically it's working now but only in public channels, i think the error is related to another config, let me explain you:
the server's main IP is 3.83.87.137
in that server i have multiple projects:
/var/www/html/test1
/var/www/html/erp
/var/www/html/test, etc.
The IP (3.83.87.137) is pointing to /var/www/html/erp, but i'm configuring and using test1 first. I believe that i can't authenticate because pointing my laravel-echo-server.json authHost to 3.83.87.137:8000 is pointing to /var/www/html/erp, am i right? Should i change my configuration so 3.83.87.137 points to /var/www/html/ o i can configure my laravel-echo-server.json authHost to 3.83.87.137:8000/test1?
Thank you so much for your help!
I have a service that I want to proxy with Connect and followed the instructions on HashiCorp Learn portal.
This is my "hello" service:
{
"service": {
"name": "node",
"port": 3000,
"connect": {
"sidecar_service": {}
}
}
}
I then do a "consul reload" and create the proxy with
consul connect proxy -sidecar-for node &
When I create another service like this
consul connect proxy -service web -upstream node:9191
I can verify that I can reach my node service by calling the web service on port 9191 (curl localhost:9191). But when I define my web service in a json file as shown below, then register it (with consul reload) and want to connect to it, I have the following error:
curl: (7) Failed to connect to localhost port 9191: Connection refused
web.json
{
"service": {
"name": "web",
"connect": {
"sidecar_service": {
"proxy": {
"upstreams": [
{
"destination_name": "node",
"local_bind_port": 9191
}
]
}
}
}
}
}
Is there anything I missed?
I am following this tutorial https://learn.hashicorp.com/consul/getting-started/connect
at the point when I ran consul connect proxy -sidecar-for web it started throwing this error:
2020-07-26T14:30:18.243+0100 [ERROR] proxy.inbound: failed to dial: error="dial tcp 127.0.0.1:0: connect: can't assign requested address"
why this does not have port assigned in his demonstration ?
{
"service": {
"name": "web",
"connect": {
"sidecar_service": {
"proxy": {
"upstreams": [
{
"destination_name": "socat",
"local_bind_port": 9191
}
]
}
}
}
}
}
The video in the tutorial shows the forth line as:
"port": 8080,
The documentation is missing that line. Not that it will matter because nothing is listening on web service so the error will persist. You can safely ignore that. I suspect your issue is that the operation nc 127.0.0.1 9191 is failing. I address that below.
The full config should look like:
{
"service": {
"name": "web",
"port": 8080,
"connect": {
"sidecar_service": {
"proxy": {
"upstreams": [
{
"destination_name": "socat",
"local_bind_port": 9191
}
]
}
}
}
}
}
But, this isn't important for getting through this section of the lab. The instructions aren't clear but don't forget to restart web proxy consul connect proxy -sidecar-for web and start socat proxy consul connect proxy -sidecar-for socat
The last part is sorely missing from the instructions and the video.
I have some apis, and a api-gateway in front of them. It happens to be Ocelot
this is my configuration on my local environment:
"ReRoutes": [
{
"DownstreamPathTemplate": "/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 5000
}
],
"UpstreamPathTemplate": "/api1/{everything}",
"UpstreamHttpMethod": [ "Get", "Post" ]
},
the api is running as Kestrel. No docker.
On the production system however it should be installed in IIS
The problem is this:
on my locan environment all apis, nad the api gateway run on localhost, nad have a port. But on the server, they are installed as Websites, and Application inside the website. so if the website's address is xyz.com, api1's address is xyz.com/api1. and it is available. I don't want it to be available, only via the api gateway. The first quesrtion is, how to make in available only via the api gateway.
And the second issue is, it doesn't work. This is my configuration on the server:
"ReRoutes": [
{
"DownstreamPathTemplate": "/Api1Api/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost", <-- here I tried xyz.com too
"Port": 80
}
],
"UpstreamPathTemplate": "/Api1/{everything}",
"UpstreamHttpMethod": [ "Get", "Post" ]
},
If I go to xyz.com/Api1Api it is working, but I don't want it to work, but if I go to xyz.com/ApiGateway/Api1, it is not working, but I want it to work from there
This is my part of my config:
"selenium": {
"start_process": true, // tells nightwatch to start/stop the selenium process
"server_path": "./selenium-server-standalone-3.8.1.jar",
"host": "127.0.0.1",
"port": 4444, // standard selenium port
"cli_args": {
"webdriver.chrome.driver": "./chromedriver_win32/chromedriver.exe"
}
},
test_settings" : {
"default" : {
"use_ssl": true,
"credentials": {
"username": "admin",
"key": "secret"
},
The test was running fine until I inserted use_ssl. Now I am getting this error:
Error retrieving a new session from the selenium server
Connection refused! Is selenium server started?
{ Error: write EPROTO 101057795:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:openssl\ssl\s23_clnt.c:797:
at exports._errnoException (util.js:1020:11)
at WriteWrap.afterWrite (net.js:800:14) code: 'EPROTO', errno: 'EPROTO', syscall: 'write' }
I am trying to test a page which requires windows authentication.