tlaverdure / laravel-echo-server Goto Github PK
View Code? Open in Web Editor NEWSocket.io server for Laravel Echo
License: MIT License
Socket.io server for Laravel Echo
License: MIT License
Hello,
I would like to start the server using Socket.io, but my provider in the public directory only allows you to run static files - if I want to start Node Application (they are using Passenger).
Is there any possibility to run the application on this server or some way of passing through by node.js PHP file?
What configuration is needed in case of multi subdomain client app?
Cant figure out those referrers...
Hi I could not start server with your provided info.
I get this error:
node_modules/laravel-echo-server/dist/echo-server.js:108
emitPresenceEvents(channel, members, member, action = null) {
^
SyntaxError: Unexpected token =
Hi,
The docs show a requirement for Node 6
However it seems that by using Node 6 we have some other issues when we use gulp (laravel elixir) to generate some of the JS code.
https://github.com/laravel/elixir/issues/496
laravel/elixir#543
I'm experiencing those issues too...
Do we really need Node 6?
Don't use domains like .dev
whilst testing your echo server. You can get very strange results.
Full info and fix here:
here are my laravel-echo-server.json
{
"appKey": "o7gq6d4m56rkm3ipaphd1cqagj2lsacogbo25bgfhra05n847jcu5li68jbc",
"authHost": "http://app.local",
"authEndpoint": "/broadcasting/auth",
"database": "redis",
"databaseConfig": {
"redis": {
"host": "redis",
"port": "6379",
"db": "0"
},
"sqlite": {
"databasePath": "/database/laravel-echo-server.sqlite"
}
},
"devMode": true,
"host": "0.0.0.0",
"port": "6001",
"referrers": [],
"socketio": {},
"sslCertPath": "",
"sslKeyPath": ""
}
It says ECONNREFUSED
. It's lookup DNS from app.local from /etc/hosts
. And it uses 127.0.0.1 as the DNS lookup result for authHost. That's the problem !
I've change the authHost to http://www.google.com
, that's the result:
So I change the authHost to my LAN IP like http://10.1.199.204
, and bind all my project entrance to http://10.1.199.204
, problem solved.
Hi there!
Would it be possible to add a configuration option that allows us to set the port of the Laravel instance used for auth?
I'm currently using Cloud9 as my editor and Apache is running on port 8080. I tried specifying the port in the "authHost" config option, but to no avail.
{
"authHost": "127.0.0.1:8080"
}
Thanks!
I am currently using laravel passport for oauth2 as my authorization for my broadcast auth.I have a short-lived access token and will expire every 1 hour. When I try to pass an invalid or expired access token, echo server would log an error that it can't authenticate request "Could not send authentication request" but the connection from the client is still alive. Client can't determine if it was successfully connected and can listen to channels or not.
Based on the ReadMe attached to this package, I added the SSL certificates to my server.js file as described, but I'm still not able to connect. I had everything running locally just fine. Do you have any tips for troubleshooting or general suggestions for what might be happening? I've tried connecting to the following, none of which I've been able to get working.
https://mydomain.com:6001
https://localhost:6001
https://127.0.0.1:6001
localhost:6001
127.0.0.1:6001
Some events may need to be published from the client.
Initial load of my dashboard view works correctly, subsequent revisits to that page cause the following reported by the laravel-echo-server:-
L A R A V E L E C H O S E R V E R
Starting server...
✔ Running at http://lzbusiness.dev on port 6001
✔ Channels are ready.
✔ Listening for redis events...
✔ Listening for http events...
Server ready!
undefined:1
SyntaxError: Unexpected end of input
at Object.parse (native)
at Request._callback (/usr/local/lib/node_modules/laravel-echo-server/dist/channels/private-channel.js:27:34)
at Request.self.callback (/usr/local/lib/node_modules/laravel-echo-server/node_modules/request/request.js:187:22)
at emitTwo (events.js:100:13)
at Request.emit (events.js:185:7)
at Request. (/usr/local/lib/node_modules/laravel-echo-server/node_modules/request/request.js:1044:10)
at emitOne (events.js:90:13)
at Request.emit (events.js:182:7)
at IncomingMessage. (/usr/local/lib/node_modules/laravel-echo-server/node_modules/request/request.js:965:12)
at emitNone (events.js:85:20)
at IncomingMessage.emit (events.js:179:7)
at endReadableNT (_stream_readable.js:913:12)
at _combinedTickCallback (node.js:377:13)
at process._tickCallback (node.js:401:11)
Any ideas or a nudge in the right direction would be appreciated. I'm trying to get the user's private channel up and running. Thanks in advance!
When server is initialized by the cli the verifyAuthPath & verifyAuthServer options can be omitted.
When trying to make a simple example of using Laravel and Laravel Echo Server, I get an error "Could not send authentication request."
What did I do:
$ laravel new laravel53
. Laravel app is served on http://laravel53.dev
$ npm install
$ npm install --save laravel-echo laravel-echo-server pusher-js socket.io-client
(for some reason laravel-echo
needs pusher-js
although I'm not using Pusher)$ laravel-echo-server init
with a config belowApp\Providers\BroadcastServiceProvider::class,
in config/app.php
resources/assets/js/app.js
import Echo from 'laravel-echo';
window.io = require('socket.io-client');
window.Echo = new Echo({
broadcaster: 'socket.io',
host: 'http://localhost:6001'
});
window.Echo.private('user.1')
.listen('NewMessageSent', (e) => {
console.log(e.update);
});
BroadcastServiceProvider
Broadcast::channel('user.*', function ($user, $userId) {
return true;
});
$ laravel-echo-server start
$ gulp
$ touch database/database.sqlite
.env
$ php artisan make:auth
$ php artisan migrate
http://laravel53.dev/register
, created account and landed on http://laravel53.dev/home
as authenticated userCould not send authentication request.
shows up in the terminalHi, are there any immediate or not so immediate plans to support SSL protected sockets?
Many thanks,
Tim
Hello,
i can send message on normal channel, but can't get private channel to work because of a token mismatch.
isn't laravel-echo-server or laravel-echo are supposed to automatically pass x-csrf-token and x-socket-id to the /broadcasting/auth route?
If so it's not working for me and if not what i'm missing and how can i pass them to laravel-echo-server or laravel-echo?
here is my view:
@extends('layouts/template')
@section('js')
script src="https://cdn.jsdelivr.net/vue/1.0.27/vue.js"></script>
script src="https://cdn.jsdelivr.net/vue.resource/1.0.3/vue-resource.min.js"></script>
script src="{{url('/')}}:8443/socket.io/socket.io.js"></script>
script src="{{url('/js/laravelecho.js')}}"></script>
@endsection
@section('contenu')
div id="app" class="col-lg-12 col-md-12 diffusion">
li>
div>
img class="img-rounded" src="{{url('/images/avatars/'.$avatar)}}">
div style="width:7px;display:inline-block;">
div class="bulle3 right5 inline-block align-top">
input v-model="chat_input" @keyup.enter="handleIt" placeholder="Entrez votre message ici ..." maxlength="140"/>
/div>
/div>
/li>
ul id="chatMessages">
/div>
<script type="text/javascript">
new Vue(
{
el: '#app',
ready()
{
this.listen();
},
data:
{
chat_input: '',
room: '{{Auth::user()->name}}',
},
methods:
{
handleIt: function()
{
this.$http.post('{{url('/')}}/msg',{message: this.chat_input, room: this.room});
$("#chatMessages").prepend(this.chat_input);
$("#chatMessages").scrollTop($("#chatMessages")[0].scrollHeight);
this.chat_input = '';
},
listen: function()
{
Echo.private('room.{{Auth::user()->name}}')
.listen('ChatMessageWasReceived', (e) => {
$("#chatMessages").prepend('<p>'+e.user+': '+e.chatMessage+'</p>');
$("#chatMessages").scrollTop($("#chatMessages")[0].scrollHeight);
});
Echo.join('room.{{Auth::user()->name}}')
.here((users) => {
//
})
.joining((user) => {
console.log(user.name);
})
.leaving((user) => {
console.log(user.name);
});
}
}
})
</script>
here is the content of /assets/js/laravelecho.js
window._ = require('lodash');
/**
window.$ = window.jQuery = require('jquery');
require('bootstrap-sass');
/**
window.Vue = require('vue');
require('vue-resource');
Vue.use(VueResource);
/**
Vue.http.interceptors.push((request, next) => {
request.headers['X-CSRF-TOKEN'] = Laravel.csrfToken;
next();
});
/**
import Echo from "laravel-echo"
window.Echo = new Echo({
broadcaster: 'socket.io',
host: 'https://example.com:8443'
});
here is laravel-echo-server.json:
{
"appKey": "e713e9en1ojlrnadm4ffftqqa7a2isqg6n260obm44n1lc269q5m4sd4g5qc",
"authHost": "https://example.com",
"authEndpoint": "/broadcasting/auth",
"database": "redis",
"databaseConfig": {
"redis": {}
},
"devMode": false,
"host": "example.com",
"port": "8443",
"protocol": "https",
"referrers": [],
"sslCertPath": "/etc/letsencrypt/live/example.com/fullchain.pem",
"sslKeyPath": "/etc/letsencrypt/live/example.com/privkey.pem",
"verifyAuthPath": true,
"verifyAuthServer": true
}
Hi,
Firstly I'm going to admit I'm not 100% knowledgeable in this area, however I think there's been some biggish change in the latest release with regards to what network adapter the echo server binds to when it is started.
I've been hitting my head against the wall for the past 3 hours until I finally "cracked it". But I'm looking for feedback.
This is not the order in which I discovered everything, but it's the most logical easy to follow order to explain.
First I check that nothing is running on port 6001 on my server.
vagrant@homestead ~/Code/new.wn.dev sudo netstat -tulnp | grep 6001
vagrant@homestead ~/Code/new.wn.dev
Nothing is returned.
Then I start my node server (this is my server.js file):
var echo = require('laravel-echo-server');
var options = {
authHost: 'http://new.wn.dev',
authPath: '/broadcasting/auth',
host: 'http://new.wn.dev',
port: 6001,
};
echo.run(options);
Now lets take a look at what is listening on port 6001
vagrant@homestead ~/Code/new.wn.dev sudo netstat -tulnp | grep 6001
tcp6 0 0 :::6001 :::* LISTEN 8337/node
Notice the 0:::
before the 6001, I think that means all adapters. I stand to be corrected.
I was able to get public, private and presence channels all working with this setup with no issues.
Lets create the json file:
{
"appKey": "k<snip>fh",
"authEndpoint": "/broadcasting/auth",
"authHost": "http://new.wn.dev",
"database": "redis",
"databaseConfig": {
"redis": {},
"sqlite": {
"databasePath": "/database/laravel-echo-server.sqlite"
}
},
"devMode": false,
"host": "http://new.wn.dev",
"port": "6001",
"protocol": "http",
"referrers": [],
"sslCertPath": "",
"sslKeyPath": "",
"verifyAuthPath": true,
"verifyAuthServer": false
}
trying to run this causes an immediate error due #26.
This seems to be because passing http
or https
to the http.listen
method is not valid. So lets hard code the host to a string without http
Editing the laravel-echo-server/dist/server.js
file near the bottom:
Lets run the server again.
Seems to be working. Now lets see what is listening on port 6001
vagrant@homestead ~/Code/new.wn.dev sudo netstat -tulnp | grep 6001
tcp 0 0 127.0.1.1:6001 0.0.0.0:* LISTEN 9781/laravel-echo-s
A-ha! This time the server is only listening to port 6001 on localhost/127.0.1.1
so even though I have my ports forwarded from 6001 on the host to 6001 on this guest, I can never contact this server on port 6001 because it only accepts connections on the local loopback adapter. Not from "external" connections.
So that got me thinking, what if I set my server address to ALL adapters (0.0.0.0).
I REMOVED the file edit in the laravel-echo-server/dist/server.js
file as well.
{
//<snip>
"devMode": false,
"host": '0.0.0.0',
"port": "6001",
"protocol": "http",
"referrers": [],
"sslCertPath": "",
"sslKeyPath": "",
"verifyAuthPath": true,
"verifyAuthServer": false
}
And start the sever again:
Well that's working. Lets see whats using the port
vagrant@homestead ~/Code/new.wn.dev sudo netstat -tulnp | grep 6001
tcp 0 0 0.0.0.0:6001 0.0.0.0:* LISTEN 9155/laravel-echo-s
Well that looks much closer to the original one in version 0.9.65
.
Lets see if it works in the browser:
Perfect!
Now everything is working again!
So a few thoughts:
:::6001
and 0.0.0.0:6001
Thank you.
Hi there,
I'm using a clean installed Node.js version 6.7.0 and trying to install laravel-echo-server
globally.
However, there seems to be a problem with renaming the abbrev
module.
Do you have any idea how to solve this issue? Should I downgrade to a another Node.js version?
MacBook-Pro:scaffolding Sander$ npm install -g laravel-echo-server
> [email protected] preinstall /Users/Sander/.nvm/versions/node/v6.7.0/lib/node_modules/.staging/sqlite3-559f54a7
> npm install node-pre-gyp
/Users/Sander/.nvm/versions/node/v6.7.0/bin/node-pre-gyp -> /Users/Sander/.nvm/versions/node/v6.7.0/lib/node_modules/node-pre-gyp/bin/node-pre-gyp
/Users/Sander/.nvm/versions/node/v6.7.0/lib
└── [email protected]
/Users/Sander/.nvm/versions/node/v6.7.0/lib
└── (empty)
npm ERR! Darwin 16.0.0
npm ERR! argv "/Users/Sander/.nvm/versions/node/v6.7.0/bin/node" "/Users/Sander/.nvm/versions/node/v6.7.0/bin/npm" "install" "-g" "laravel-echo-server"
npm ERR! node v6.7.0
npm ERR! npm v3.10.3
npm ERR! path /Users/Sander/.nvm/versions/node/v6.7.0/lib/node_modules/.staging/abbrev-309fa9ed
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/Users/Sander/.nvm/versions/node/v6.7.0/lib/node_modules/.staging/abbrev-309fa9ed' -> '/Users/Sander/.nvm/versions/node/v6.7.0/lib/node_modules/laravel-echo-server/node_modules/abbrev'
npm ERR! enoent ENOENT: no such file or directory, rename '/Users/Sander/.nvm/versions/node/v6.7.0/lib/node_modules/.staging/abbrev-309fa9ed' -> '/Users/Sander/.nvm/versions/node/v6.7.0/lib/node_modules/laravel-echo-server/node_modules/abbrev'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! Please include the following file with any support request:
npm ERR! /Users/Sander/Sites/scaffolding/npm-debug.log
npm ERR! code 1
With Pusher.io Laravel Echo will send the current user's socket id to the session so that Laravel doesn't broadcast events to the current user in some situations.
Is this functionality non-existent with redis/socket.io setup?
I'm trying to connect to a presence channel and the laravel echo server dies.
I noticed in the file node_modules/laravel-echo-server/dist/channels/channel.js
that you have this._privateChannels = ['private-*', 'presence-*']
.
Should presence be a private channel? When I switch this off it works.
I'm trying to use this package, but I can't get private channels to work.
I've the latest version of both this package as Laravel running, node updated etc.
I keep getting this error:
Error: Invalid URI "intranet.dev/broadcasting/auth"
Could not send authentication request.
My laravel-echo-server.json file:
{
"appKey": "nkmn0uh71d1s3mhdlqq5kqkp16mg3rup4rho97t13qj3ghag30i8q1j3egr2",
"authEndpoint": "/broadcasting/auth",
"authHost": "http://intranet",
"database": "redis",
"databaseConfig": {
"redis": {},
"sqlite": {
"databasePath": "/database/laravel-echo-server.sqlite"
}
},
"devMode": false,
"host": "intranet",
"port": "6001",
"protocol": "http",
"referrers": [],
"sslCertPath": "",
"sslKeyPath": "",
"verifyAuthPath": true,
"verifyAuthServer": true
}
Client JavaScript code:
import Echo from 'laravel-echo'
window.Echo = new Echo({
broadcaster: 'socket.io',
host: 'http://intranet:6001'
});
What am I doing wrong?
Okay... I think I found out what the problem might be. The intranet website uses Windows-Authentication and so IIS is blocking the request before it even gets to the Laravel app...
Is there any way to specify Windows credentials to use for the request?
I run this code in js console:
window.Echo.channel('tickets')
.listen('ticket.created', function(e){
console.log(e.order.name);
});
and see this in laravel-echo-server cli:
$ laravel-echo-server start
L A R A V E L E C H O S E R V E R
⚠Starting server in DEV mode...
✔ Running at localhost on port 6001
✔ Channels are ready.
✔ Listening for http events...
✔ Listening for redis events...
Server ready!
[18:04:10] - S8LMlDg5BngTibDtAAAB joined channel: tickets
[18:04:10] - S8LMlDg5BngTibDtAAAB left channel: tickets
laravel-echo-server.json:
{
"appKey": "myAppKeyFrom.env",
"authHost": "http://localhost/",
"authEndpoint": "/broadcasting/auth",
"database": "redis",
"databaseConfig": {
"redis": {
"host": "localhost",
"port": 6379,
"db": 0
}
},
"devMode": true,
"host": "localhost",
"port": "6001",
"referrers": [
],
"socketio": {},
"sslCertPath": "",
"sslKeyPath": "",
"verifyAuthPath": true,
"verifyAuthServer": false
}
bootstrap.js
window.Echo = new Echo({
broadcaster: 'socket.io',
host: 'http://localhost:6001'
});
Hi guys,
Great work on this! I've just managed to get my head around it and once again the Laravel community has outdone itself.
I just wanted to point something out for anyone starting out with this package, which wasn't immediately clear to me.
I had issues getting this to work with presence channels. When authenticating user against the channel, it was throwing a 404 error for the /broadcasting/auth route. Digging in, I found that the default authHost was http://localhost, which makes sense, but this wasn't the correct address for my laravel app via homestead.
When I specified the "authHost" in "server.js" with what was configured in homestead (e.g. 'http://app.dev'), then this worked fine.
This may be obvious to some, but I spent a few hours trying to crack this one!
Otherwise, thank you very much for your efforts!
It spikes from 0 to 35%. Is there any reason for it?
Imagine that the Laravel Event/Broadcast system has fired a event, and has sended
to Redis, to be broadcasted on channel user.1234.
But, at this time, the user 1234 is not logged in, so it is not listening on channel user.1234.
laravel-echo-server will pick-up the redis message, and "discard", as the message will
be sented to a channel with no one.
Laravel-echo-server could hold this message for a period of time,
maybe a paramenter on payload, for a time?
Mayble, laravel-echo-server could check if there is at least one user in that channel,
and if there is no one, try latter, or maybe queue for delivery when someone join in
that channel.
I'll keep it short. I'm using Laravel homestead. At first, I was being dumb and I was trying to start the server outside of the vm. It would startup normally, my site just wouldn't be able to access it. When I finally started running it in the vm, I got this stack trace:
/home/vagrant/Projects/Blog/node_modules/laravel-echo-server/dist/echo-server.js:159
emitPresenceEvents(socket, channel, members, member, action = null) {
^
SyntaxError: Unexpected token =
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:387:25)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/home/vagrant/Projects/Blog/node_modules/laravel-echo-server/dist/index.js:2:23)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
Is this something I'm doing? Thanks.
Hi all.
Disclaimer. This works curectly with Pusher (so at least that's out of the way).
I started yesterday working on a project using Laravel echo and i wanted to use socket.io instead of pusher. So as suggested by Taylor on the official documentation, i went ahead and pulled in https://github.com/tlaverdure/laravel-echo-server
Doing this on Homestead.
Got everything working fine with public events.
The issues started with private channels.
As expected, and defined in the BroadcastServiceProvider, i need to send auth requests to /broadcasting/auth. The problem is i get a constant token mismatch exception.
Investigating further in Illuminate\Foundation\Http\Middleware\VerifyCsrfToken and specifically in the tokensMatch function, i notice that
$sessionToken = $request->session()->token();
and
$token = $request->input('_token') ?: $request->header('X-CSRF-TOKEN');
have two different values. The one in the headers being the one of the authenticated session (so the correct one).
Moving further i was initially using redis as session store. Then i moved into file and noticed that for every request to /boadcasting/auth a new session was being generated.
In the end starting storing sessions into the database. Here's where the final clue came.
For every request coming from homestead (where node and laravel are, thus Echo is running) I am getting a new session generated with Homestead's ip 192.168.10.10 for every time i load the page. So naturally the sessions would not match but i can't figure out how to avoid it.
Additionally, even moving the application out of homestead yielded the same results.
-Basically echo server is unable to tell Laravel the currently logged in user.
I've cleared all caches, dumped autoload, cleared compiled, even rebuilt the vendor folder a couple of times.
At this point i have no idea anymore. I'd really appreciate if someone could shed some light.
Thanks in advance
Hi to all,
i'm a bit confused on how setup this server with Laravel.
Right now i have a working configuration with Pusher, and i would like to test this server.
laravel-echo-server can use sqlite and redis. In .env
the BROADCAST_DRIVER
should be redis
in both case ?
I have setup all, when i visit the page with server up the connection is established (i notice that because if i stop the server, Chrome Dev tools log errors), but when i try to send messages.. that are not dispatched. And, with pusher the configuration works fine (i'm just trying to change the server).
Can someone tell me how to configure server and how to setup Laravel ?
Thanks a lot
This might also be related to #8
My setup in server.js
during development is to use a .dev
url on Homestead.
I was having no issues using normal channels and then I started to play with private channels. I was having very strange results where I could only listen to a broadcasted event in my private channel about 30% of the time.
So I knew it was working, and that it was authorising ok, only about 70% of the time I was testing I couldn't receive the event....
After a lot of debugging I finally found out that the serverRequest
sent by laravel-echo-server
to my authHost
url was taking exactly 2mins to get a response.
I added some console.log
here and this is what I got when I ran the server:
✘ vagrant@homestead ~/Code/new.nn.com node server.js development
EchoServer: "Server running at http://new.wn.dev:6001"
authentication {"url":"http://new.wn.dev/broadcasting/auth","form":{"channel_name":"private-App.User.1"},"headers":{"X-CSRF-TOKEN":"ktHclK1jxdnerkkV49df1r0LyydcOuHHjcoxXafH"},"rejectUnauthorized":false}
About to send Request at 1472463808
Response received at 1472463928
Because I wasn't always waiting the full 2 mins before firing an event, it appeared to me that the channel wasn't working when in fact I just hadn't authorised yet. If I waited the 2 mins then fired my events, I got them every single time.
2 mins seemed like a very precise time, so i did some more testing.
If I changed it to a normal URL (say google.com), the request was sent instantly and I got a response (albeit an incorrect one), but as soon as I tried setting it back to my development URL it took exactly 2 mins again.
That makes me believe that there's some issue with the dnslookup for sending requests. It seems like it was trying to lookup my .dev
URL on the internet, and not use my local dns /etc/hosts
to route directly back to the same server. It appears that it's set for a timeout of 120 secs before it gives up on looking online and reverts back.
Again I know very little about Node.js
, but from what i can gather, it seems like you are using the Request
library, and when I went looking in there it seems like the Request
library using the core Node.js
library to deal with dns lookups etc.
SO. Do you have any idea how to fix this? Is there something in your library we can add as a request option? Is the a bug in the Request
library, is it a Node.js
issue? That's as far as I could debug too and now I need some help if you are able!?
Thank you.
{ "appKey": "90mf4eojc6ogu4sfpg4g12i9escptj68p1qg2iu34rmnr09d58lj7f5h4j4g", "authEndpoint": "/broadcasting/auth", "authHost": null, "database": "sqlite", "databaseConfig": { "redis": {}, "sqlite": { "databasePath": "/database/laravel-echo-server.sqlite" } }, "devMode": false, "host": "https://project.app", "port": "6001", "referrers": [ { "host": "pasta-masta.app", "apiKey": "44ter5dm3isq6p89f8s1ufufkfo4jddun22ijbga617sedige4lsj9c8mc0r" } ], "sslCertPath": "/home/user/.valet/Certificates/pasta-masta.app.crt", "sslKeyPath": "/home/user/.valet/Certificates/pasta-masta.app.key" }
The problem is with host attribute. It works without "https://" prefix. But I need SSL.
Hello, I'm using this package with Redis. When I use normal channels like Echo.channel('users').listen('UserSignedUp')
I do receive the event client side, but when I use private channels, nothing happens. Even though I see that the event was fired in the Redis console.
I'm not sure if this is a problem with this package or with Echo itself. I wonder if someone else is having the same issue?
{
"appKey": "9asdfasdfasdfasdf70kfojbcdos6tujq8f10celag0a9s0",
"authEndpoint": "/broadcasting/auth",
"authHost": null,
"database": "redis",
"databaseConfig": {
"redis": {},
"sqlite": {
"databasePath": "/database/laravel-echo-server.sqlite"
}
},
"devMode": false,
"host": "mydomain.com",
"port": "6001",
"protocol": "https",
"referrers": [],
"sslCertPath": "/etc/letsencrypt/live/mydomain.com/cert.pem",
"sslKeyPath": "/etc/letsencrypt/live/mydomain.com/privkey.pem",
"verifyAuthPath": true,
"verifyAuthServer": false
}
everything work well if when using http , but if use https even the js file cannot be load in client side,
do i need to config nginx (port forwarding?) for it to work
Is there any way to configure the redis server host and port?
authEndpoint - what i must return from this route? Help me, please. Two days and two nights i tried run laravel 5.3 notification with redis and socket io.
So even though I have $this->dontBroadcastToCurrentUser();
in the constructor for a public event it is still being sent to the current user. I've checked and my Echo client is sending the X-Socket-Id
header so that laravel-echo-server
should be able to filter out events for the current user's socket id but I'm not sure where to start debugging this.
Hi everyone!
I'm trying to run this on homestead and keep getting the same error (server boots, seems ok, then when I load a page that tries to connect to it I get this:
L A R A V E L E C H O S E R V E R
Starting server...
✔ Running at nevermind.dev on port 6001
✔ Channels are ready.
✔ Listening for redis events...
✔ Listening for http events...
Server ready!
undefined:1
SyntaxError: Unexpected end of input
at Object.parse (native)
at Request._callback (/usr/lib/node_modules/laravel-echo-server/dist/channels/private-channel.js:28:28)
at Request.self.callback (/usr/lib/node_modules/laravel-echo-server/node_modules/request/request.js:187:22)
at emitTwo (events.js:100:13)
at Request.emit (events.js:185:7)
at Request. (/usr/lib/node_modules/laravel-echo-server/node_modules/request/request.js:1048:10)
at emitOne (events.js:90:13)
at Request.emit (events.js:182:7)
at IncomingMessage. (/usr/lib/node_modules/laravel-echo-server/node_modules/request/request.js:969:12)
at emitNone (events.js:85:20)
at IncomingMessage.emit (events.js:179:7)
at endReadableNT (_stream_readable.js:913:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
I got into the code as much as I could.
This line:
/usr/lib/node_modules/laravel-echo-server/dist/channels/private-channel.js:29:28
is just:
resolve(JSON.parse(body));
body is an empty string.
{
"appKey": "haa9i61b1rrcrmql5p55715lf4erjkp6fu3s56h1pbcgr761tcj3p9h1e51u",
"authEndpoint": "/broadcasting/auth",
"authHost": "http://nevermind.dev",
"database": "redis",
"databaseConfig": {
"redis": {},
"sqlite": {
"databasePath": "/database/laravel-echo-server.sqlite"
}
},
"devMode": true,
"host": "nevermind.dev",
"port": "6001",
"protocol": "http",
"referrers": [],
"sslCertPath": "",
"sslKeyPath": "",
"verifyAuthPath": true,
"verifyAuthServer": false
}
url: http://nevermind.dev:6001/socket.io/
query string:
EIO:3
transport:polling
t:LTxGwYh
sid:kZSoIO2cXRg2AC8dAAAC
response:
�ÿ6
url: http://viewsity.dev:6001/socket.io/
query string:
EIO:3
transport:polling
t:LTxGwYg
sid:kZSoIO2cXRg2AC8dAAAC
payload:
131:42["subscribe",{"channel":"private-conversation.4","auth":{"headers":{"X-CSRF-TOKEN":"Hcrbjah7JkYVWclvgrs7vKmhKI6OOSc1l40Tdgrb"}}}]
response:
ok
url: http://nevermind.dev:6001/socket.io/
query string:
EIO:3
transport:polling
t:LTxGwX5
sid:kZSoIO2cXRg2AC8dAAAC
response:
�ÿ40
url: http://viewsity.dev:6001/socket.io/
query string:
EIO:3
transport:polling
t:LTxGwV_
response:
�ÿ0{"sid":"kZSoIO2cXRg2AC8dAAAC","upgrades":["websocket"],"pingInterval":25000,"pingTimeout":60000}
Does anyone know how to solve this?
Can anyone who managed to make this work on homestead reply with their laravel-echo-server.json?
Thanks!
When server starts, show the running version.
I have the server running great. I am running Laravel 5.3-RC1. I am having a tough time figuring out where to put my socket.io client js code, and what it should be. Any help would be appreciated!
events.js:160
throw er; // Unhandled 'error' event
^
Error: SQLITE_ERROR: index key_index already exists
at Error (native)
if i removed the sqlite file and re-added it again, the error goes away.
So I've gotten everything all setup, and so far public channels are working perfectly Laravel Echo receives events properly and all.
But it seems as though this package can not auth itself at /broadcasting/auth
I've poured over all these docs and issues and even closed ones where I've seen some people have the same issue but their fix didn't help me.
I'm working on Laravel Homestead using (gamejerks.app). Laravel-echo-server is running on the VM/Vagrant. Obviously Laravel Echo runs in the browser. I feel this is the issue because gamejerks.app
is only usable to reach the VM is from Windows, not within the VM which is where this package is running.
Here's my config:
{
"appKey": "{removed}",
"authEndpoint": "/broadcasting/auth",
"authHost": "http://gamejerks.app",
"database": "redis",
"databaseConfig": {
"redis": {},
"sqlite": {
"databasePath": "/database/laravel-echo-server.sqlite"
}
},
"devMode": false,
"host": "gamejerks.app",
"port": "6001",
"protocol": "http",
"referrers": [],
"sslCertPath": "",
"sslKeyPath": "",
"verifyAuthPath": true,
"verifyAuthServer": false
}
And my Laravel Echo config:
import Echo from "laravel-echo";
window.Echo = new Echo({
broadcaster: 'socket.io',
host: 'http://gamejerks.app:6001'
});
Any help would be much appreciated because I'd love to switch to a local event server vs using pusher.io forever because the considerable lag in requests to the 3rd party.
I can't get it to work inside a Docker container. If I do this:
docker-compose exec app curl http://localhost:6001/socket.io/socket.io.js
then it works, but if I do this:
curl http://localhost:6001/socket.io/socket.io.js
then the connection is "reset by peer".
The port 6001 is open, if I put anything else on it then I can access it.
I think I might be confused regarding what a referrer is here. If it's inside Docker and all the server names are "localhost", do I need to use laravel-echo-server referrer:add
anyway? I tried it with a few different values ("localhost", the IP of the container, the service name of the container) but none of them worked for me.
The server doesn't seem to start. When I run the command:
laravel-echo-server start
I get this error
My laravel-echo-server.json is as follows:
{ "appKey": "j6rb6p9jqibi05s8ljdioro5gptj78928bnuacj3qh2tl5i508qfg6hsok2t", "authEndpoint": "/broadcasting/auth", "authHost": null, "database": "redis", "databaseConfig": { "redis": { "port": "6379", "host": "http://127.0.0.1" }, "sqlite": { "databasePath": "/database/laravel-echo-server.sqlite" } }, "devMode": false, "host": "http://dashboard.app", "port": "6001", "referrers": [], "sslCertPath": "", "sslKeyPath": "" }
options.devMode = yargs.argv.dev || false;
this makes setting devMode to true from config file impossible.
L A R A V E L E C H O S E R V E R
Starting server...
✔ Running at something.com on port 6001
✔ Channels are ready.
✔ Listening for redis events...
✔ Listening for http events...
Server ready!
events.js:160
throw er; // Unhandled 'error' event
^
Error: listen EADDRNOTAVAIL 104.31.85.98:6001
at Object.exports._errnoException (util.js:1036:11)
at exports._exceptionWithHostPort (util.js:1059:20)
at Server._listen2 (net.js:1239:19)
at listen (net.js:1288:10)
at net.js:1398:9
at GetAddrInfoReqWrap.asyncCallback [as callback] (dns.js:62:16)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:81:10)
here is the init info aswell
{
"appKey": "xxx",
"authEndpoint": "/broadcasting/auth",
"authHost": "",
"database": "redis",
"databaseConfig": {
"redis": {},
"sqlite": {
"databasePath": "/database/laravel-echo-server.sqlite"
}
},
"devMode": false,
"port": "6001",
"referrers": [],
"verifyAuthPath": true,
"verifyAuthServer": true,
"host": "something.com",
"protocol": "https",
"sslCertPath": "/etc/nginx/ssl/something.com/server.crt",
"sslKeyPath": "/etc/nginx/ssl/something.com/server.key"
}
and here is the console error
socket.io.js:3511 GET https://something.com:6001/socket.io/?EIO=3&transport=polling&t=LUD08rI net::ERR_CONNECTION_REFUSED
After updating this package today my site stopped working.
When reading the laravel-echo-server docs i went crazy because it did not tell me how to start the damn thing, after reading the issues i found out that i should use "laravel-echo-server start" to run.
Oke it works fine now!
But int the previous version i could run a server,js file, i used https://github.com/coreybutler/node-windows to start the server.js on windows start, but with the updated version i cannot do this anymore (i think) does someone know how i can run "laravel-echo-server start" command when windows has started?
Socket.io has some useful options: https://github.com/socketio/engine.io#methods-1
It'd be nice if we could specify these options in the config to be passed through.
One example use-case is to swap out socket.io's websocket engine with uws
: https://github.com/uWebSockets/uWebSockets, which claims to be 10-300x faster than socket.io's default engine (ws
)
Here is my trick to make apache forward requests to laravel-echo-server/socket.io
in a transparent way.
With this approach, we can setup you laravel-echo-server to listen just on localhost - in this example port 3001, and set you laravel js side like this.
When you fireup you browser, a websocket connection will be tried on same host
and same port as your app is running, and then forwarded internally by apache to laravel-echo-server.
Problem with firewalls..no more...
You need the modules proxy_http e proxy_wstunnel up.
The code above must be insider your virtual-host paste-bin
hi, i want to ask
are there any best practice using Laravel Echo Server On Production Server as background service
like queue process on laravel documentation suggestion using supervisord,
is Laravel Echo Server can be run with pm2 or nodaemon?
thanks a lot
any idea ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.