laravel-echo-server icon indicating copy to clipboard operation
laravel-echo-server copied to clipboard

Unable to connect with `laravel-echo-server` with latest `socket.io-client`

Open kartiksprajapati opened this issue 4 years ago • 9 comments

Describe the bug Whenever I try to connect with laravel-echo-server with the latest socket.io-client and laravel-echo, it does not connect to the laravel-echo-server, however If I downgrade socket.io-client version to 2.3.0, it works like charm.

I don't know why it is failing

To Reproduce Steps to reproduce the behavior:

  1. Install laravel-echo and socket.io-client on fresh vue project.
  2. Add this code to src/main.js
window.io = require('socket.io-client');

window.Echo = new Echo({
    broadcaster: "socket.io",
    host: "http://localhost:6001",
    transports: ["websocket"]
});

window.Echo.channel('user-channel')
    .listen('UserEvent', e => {
        console.log(e);
        alert(e.name);
    });

window.Echo = Echo;
  1. But, If I downgrade to v2.3.0, then it works, same version as of socket.io in laravel-echo-server/package.json

Expected behavior It should connect to the laravel-echo-server but won't connect

Additional context But, if the socket.io-client downgrade to v2.3.0 it works, not working with the latest version.

kartiksprajapati avatar Jun 05 '21 14:06 kartiksprajapati

Just came across the same issue downgrading worked

mattvb91 avatar Jun 06 '21 16:06 mattvb91

And, downgraded version is also not safe

kartiksprajapati avatar Jun 06 '21 18:06 kartiksprajapati

#572 might be a fix but I havent had the chance to check it yet, looks like this repo is abandoned

mattvb91 avatar Jun 06 '21 18:06 mattvb91

yaa... that's true I think so... I will try that package soon...

kartiksprajapati avatar Jun 06 '21 18:06 kartiksprajapati

Because socket.io is using version 2 https://github.com/tlaverdure/laravel-echo-server/blob/6a4125d96d238c2e99c09c9918925ef6322aca35/package.json#L32 the client must also use version 2

nguyentranchung avatar Jun 10 '21 23:06 nguyentranchung

When i downgraded socket.io-client to 2.3.0 it works

bradleyking-dev avatar Jun 26 '21 12:06 bradleyking-dev

Because socket.io is using version 2

https://github.com/tlaverdure/laravel-echo-server/blob/6a4125d96d238c2e99c09c9918925ef6322aca35/package.json#L32

the client must also use version 2

https://socket.io/docs/v4/client-installation/index.html

image

dof-wmy avatar Sep 07 '21 06:09 dof-wmy

Here is discussion how to get it working for me works with socket.io-client v4 https://github.com/laravel/echo/issues/290#issuecomment-950324453

rrolla avatar Oct 24 '21 13:10 rrolla

Is this will be fixed or never ?

rroblik avatar Apr 06 '22 10:04 rroblik