This is probably the most frustrating thing I have ever encountered, sadly it's probably something stupid that I did.
Here are the links to the three things that I'm using:
Here is my problem: my website is continually hitting this route: http://192.168.10.10:6001/socket.io
. I don't know why it is hitting this route, because I havn't defined the socket.io
part anywhere in my code. Here is the code I used in my bootstrap.js to instantiate Laravel Echo.
import Echo from "laravel-echo"
window.Echo = new Echo({
broadcaster: 'socket.io',
host: 'http://192.168.10.10:6001'
});
And this is the code in my socket.js file (node.js):
var echo = require('laravel-echo-server');
var options = {
authHost: 'http://192.168.10.10',
authPath: '/broadcasting/auth',
host: 'http://192.168.10.10',
port: 6001
};
echo.run(options);
So far, there is nothing here that could possibly be going wrong. Here is the error message that links back to the cdn. The strange thing is that changing window.Echo
host changes the domain, but I don't know how to change that socket.io part.
This makes you wonder, is it hard coded somewhere in the Socket.io file? This is my first time using Socket.io, so I have no way to know. Maybe After I put in the cdn there is extra setup that I need to do? All the Laravel docs says to do is add the script tag, and Laravel is known for having fantastic documentation.
Any expertise would be much appreciated, enlighten me!
MMMTroy suggested that I start my socket.io server in the vm instead of my regular computer. This made perfect sense, and is probably the issue. But now I am having another problem. Before, I was just start up the server (on my regular computer) and it would say: EchoServer: "Server running at http://192.168.10.10:6001"
. Now, when I attempt to start the server on my vm, it returns this error:
/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)
What should I do about this error? I looked at laravel-echo-server emitPresenceEvents function but I had no idea what was going on.
Thanks.
I finally fixed it, it had something to do with the node version. I updated homesteads node to the latest version and that fixed it.
For me, I have to start my socket from my virtual machine, rather than my local setup. Try starting your server from the root of your project via your virtual machine (homestead/vagrant) rather than your computer's normal folder structure.