1

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.

Screenshot:

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!

Update

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.

Fixed!

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.

Dastur
  • 684
  • 6
  • 23
  • Are you importing yet? – MMMTroy Sep 03 '16 at 03:30
  • Sorry, based on the error you added at the end, your site must be trying to connect to your socket based on the file I mentioned above. I think you must have added this in one of your blades. The error is simply saying it can't connect to your socket. Have you started your node server? – MMMTroy Sep 03 '16 at 03:33
  • Yes the socket server is started. – Dastur Sep 03 '16 at 03:59
  • Okay. I just got this setup yesterday myself. Did you start your node server on your local machine, or on your virtual machine? I started my node server from the root folder of my project within my virtual machine (vagrant/homestead). You're actually really close. – MMMTroy Sep 03 '16 at 04:08
  • Also, I didn't need "authHost", or "authPath". Try ditching them. – MMMTroy Sep 03 '16 at 04:08
  • I started my node server regularly on my computer, but thr site id running on homestead.That is probably the issue. – Dastur Sep 03 '16 at 04:09
  • I cant check right now, but if you post an answer as soon as I can get on my computer and check Ill except the answer. – Dastur Sep 03 '16 at 04:10

1 Answers1

1

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.

MMMTroy
  • 1,256
  • 1
  • 11
  • 20