Giter VIP home page Giter VIP logo

laravel-echo-server's People

Contributors

abetwothree avatar andrewmast avatar antriver avatar aqulu avatar aserv92 avatar barryvdh avatar darkghosthunter avatar dependabot[bot] avatar devglrd avatar edstevo avatar jonnywilliamson avatar joshua-p-williams avatar kashtanoff avatar mark-win avatar marnulombard avatar mgsousa avatar mpyw avatar mrmadclown avatar namoshek avatar petecoop avatar poseidonphp avatar richriscunha avatar shulard avatar sofwar avatar stepanorda avatar taylorotwell avatar tlaverdure avatar tobiasvielmetter avatar ulc-brian avatar zeyad82 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-echo-server's Issues

Private channels, token mismatch on /broadcasting/auth route

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+':&nbsp;'+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>
@endsection

here is the content of /assets/js/laravelecho.js

window._ = require('lodash');

/**

  • We'll load jQuery and the Bootstrap jQuery plugin which provides support
  • for JavaScript based Bootstrap features such as modals and tabs. This
  • code may be modified to fit the specific needs of your application.
    */

window.$ = window.jQuery = require('jquery');
require('bootstrap-sass');

/**

  • Vue is a modern JavaScript library for building interactive web interfaces
  • using reactive data binding and reusable components. Vue's API is clean
  • and simple, leaving you to focus on building your next great project.
    */

window.Vue = require('vue');
require('vue-resource');
Vue.use(VueResource);

/**

  • We'll register a HTTP interceptor to attach the "CSRF" header to each of
  • the outgoing requests issued by this application. The CSRF middleware
  • included with Laravel will automatically verify the header's value.
    */

Vue.http.interceptors.push((request, next) => {
request.headers['X-CSRF-TOKEN'] = Laravel.csrfToken;

next();

});

/**

  • Echo exposes an expressive API for subscribing to channels and listening
  • for events that are broadcast by Laravel. Echo and event broadcasting
  • allows your team to easily build robust real-time web applications.
    */

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
}

Unable to connect to server with HTTPS

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

cannot set up ssl correctly

{
"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
}

image

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

authEndpoint - what i must return?

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.

Using in homestead virtual machine throws error.

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.

Disconnect current connection when not authenticated

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.

The server provider does not allow you to run PHP files

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?

Feature Request: authPort in configuration

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!

error running on live https server

  • Laravel v5.3.15
  • laravel-echo-server v1.0.12
  • node v6.7.0
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

redis server

Is there any way to configure the redis server host and port?

Events being duplicated

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.

Auth Request to local URL causing timeout issue.

This might also be related to #8

My setup in server.js during development is to use a .dev url on Homestead.

image

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.

image

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.

left channel after join

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'
});

How to setup laravel-echo-server

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

Best Practice Running Laravel Echo Server as Background Service

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

Using this with homestead

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!

Ack Message [question]

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.

Socket ID

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?

Multi subdomain support

What configuration is needed in case of multi subdomain client app?
Cant figure out those referrers...

Could not start server

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 =

Laravel and laravel-echo-server TokenMismatch

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

Presence channel is private

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.

Getting an error "Could not send authentication request." when trying to listen on a private channel

When trying to make a simple example of using Laravel and Laravel Echo Server, I get an error "Could not send authentication request."

screen shot 2016-09-14 at 20 33 12

What did I do:

  • I created a new fresh Laravel 5.3 project $ 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 below

screen shot 2016-09-14 at 20 39 47

  • uncommented App\Providers\BroadcastServiceProvider::class, in config/app.php
  • appended the following code to 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);
    });
  • added the following code to BroadcastServiceProvider
Broadcast::channel('user.*', function ($user, $userId) {
    return true;
});
  • $ laravel-echo-server start
  • $ gulp
  • $ touch database/database.sqlite
  • set sqlite as DB driver in .env
  • $ php artisan make:auth
  • $ php artisan migrate
  • visited http://laravel53.dev/register, created account and landed on http://laravel53.dev/home as authenticated user
  • Could not send authentication request. shows up in the terminal

Running this inside Docker

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.

Laravel-echo-server running in docker, resolve the local address as IP !

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": ""
}

5c7647c7-1150-4b48-ad9f-06b01f1c6573

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:
image

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.
0caef49e-1738-4246-85b1-1326ee1ebf17

Can't authenticate private channel, problem with Windows authentication

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?

Issue on page refresh

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!

Broadcast Auth on Laravel Homestead

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.

Apache Settings for transparent Socket.Io [trick]

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

New release is binding to localhost not all adapters.

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.

  • I'm currently using homestead to do all the development work. Nothing is being run on my "local" machine.
  • I tested using the old v0.9.65 and the latest 1.10.11
  • I have had to tweak the source files to get around #26

This is not the order in which I discovered everything, but it's the most logical easy to follow order to explain.

Using v 0.9.65

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.

Now Upgrade to 1.0.11

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.

image

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:

image

Lets run the server again.

image

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.

image

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:

image

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:

image

Perfect!

Now everything is working again!

So a few thoughts:

  1. Have I found a bug?
  2. Should we be connecting to local host or all adapters in production?
  3. Has there been a change in the code that would affect this between 0.9 and 1.0 ?
  4. Whats the difference between :::6001 and 0.0.0.0:6001
  5. Have you a time machine so I can get the past few hours back! Haha.

Thank you.

run laravel-echo-server on startup

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?

Can't get this to work on homestead

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.

Here's my laravel-echo-server.json:

{
    "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
}

on the console I get these responses from the server:

1st request:

url: http://nevermind.dev:6001/socket.io/

query string:
EIO:3
transport:polling
t:LTxGwYh
sid:kZSoIO2cXRg2AC8dAAAC

response:
�ÿ6

2nd request:

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

3rd request:

url: http://nevermind.dev:6001/socket.io/

query string:
EIO:3
transport:polling
t:LTxGwX5
sid:kZSoIO2cXRg2AC8dAAAC

response:
�ÿ40

4th (last) request

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!

Private Channels not working

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?

ENOENT: no such file or directory

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

Client side implementation

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!

getaddrinfo ENOTFOUND https://project.app

image

{ "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.

Server Won't Start

The server doesn't seem to start. When I run the command:
laravel-echo-server start
I get this error
echo server

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": "" }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.