Parth Vora
Parth Vora

Reputation: 4114

Getting continuously transport=polling 404 with laravel-echo-server package

I have a simple blog site where the user can comment on the blog. I just want to show a simple popup notification to the blog author when someone comments on his blog.

I have already read this:

https://laravel.com/docs/5.3/broadcasting#introduction

Here is what I did to achieve the task:

Setup an event, which gets fired upon new comment

Imported:

<script src="https://cdn.socket.io/socket.io-1.4.5.js"></script>

in blade template

Added in, resources\assets\js\bootstrap.js: (as per the Laravel documentation says)

import Echo from "laravel-echo"
window.Echo = new Echo({
    broadcaster: 'socket.io',
    key: 'http://blog.local:6001'
});

I have setup this package as per the: https://github.com/tlaverdure/laravel-echo-server#laravel-echo-server

Fired command: laravel-echo-server start

When, I open the web browser and check console, I'm continuously getting this errors:

socket.io-1.4.5.js:1 GET http://blog.local/socket.io?EIO=3&transport=polling&t=LZkVvZQ 404 (Not Found) Here is my "laravel-echo-server.json"

{
    "appKey": "7k2g9nlm6i492ckorlmp35ng4frusfmt4uq1n68usn3re5lcl4sfg3gibi5d",
    "authHost": null,
    "authEndpoint": "/broadcasting/auth",
    "database": "sqlite",
    "databaseConfig": {
        "redis": {},
        "sqlite": {
            "databasePath": "/database/laravel-echo-server.sqlite"
        }
    },
    "devMode": false,
    "host": "blog.local",
    "port": "6001",
    "referrers": [],
    "socketio": {},
    "sslCertPath": "",
    "sslKeyPath": ""
}

I think some issues with socket connection.

Let me know, if anyone needs some more info.

Note:

I'm not sure that, do I really need this package for my purpose or not. I just installed it because it was mentioned on Laravel's documentation. As I said I just need real time popup notification.

Any help would be appreciated.

Thanks

Upvotes: 0

Views: 1509

Answers (1)

Parth Vora
Parth Vora

Reputation: 4114

I found the issue:

import Echo from "laravel-echo"
window.Echo = new Echo({
    broadcaster: 'socket.io',
    host: 'http://blog.local:6001'
});

It should be host not the key.

Upvotes: 0

Related Questions