New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Socket.IO v3.0 support #290
Comments
It's only just released so this library isn't compatible yet. We'll look into this eventually but if anyone wants to get this done sooner you're free to send in a PR. |
Yeah, if you know how to update it please send in a PR. |
I don't work with Echo, but seems like some people are saying it's a CORS error here socketio/socket.io-client#1140 |
Got it working without any problems: With this JS: import Echo from "laravel-echo"
window.io = require('socket.io-client');
window.Echo = new Echo({
broadcaster: 'socket.io',
host: window.location.hostname + ':6001',
withCredentials: true
}); For the server I cloned the "socketio": {
"cors": {
"origin": "http://localhost",
"credentials": true
}
} All Worked well both public and private channel. |
Will try to submit a PR to solve this ASAP |
While setting up the environment to start working on this everything worked just perfect without any error, below are the versions my environment is on.
I've created a simple socket.io server with the following code const app = require('express')();
const http = require('http').createServer(app);
const io = require('socket.io')(http);
io.on('connection', (socket) => {
console.log('a user connected');
});
app.get('/', (req, res) => {
res.send('<h1>Hello world</h1>');
});
http.listen(3000, () => {
console.log('listening on *:3000');
}); import Echo from 'laravel-echo';
window.io = require('socket.io-client');
window.Echo = new Echo({
broadcaster: 'socket.io',
host: window.location.hostname, //I've already routed valet nginx file to reverse proxy the socket.io server
}); #Update Am I missing anything?? |
So it seems that Socket.IO 3.0 is working properly with Echo? Is there anything we can do in the docs to make it more clear on how to get started with Socket.IO 3.0? |
@driesvints The only thing I see is the withCredentials and cors part on the server. |
When I update I get the same
|
I am also getting "Bad Handshake Method" Can you please share a demo sample repo so that we can check our mistakes? Thanks in advance |
@anwardote dont have it on a repo, I can do that if needed, are you using a server also on the version 3? maybe is that case. |
package.json:
laravel-echo-server.json
bootstrap.js
Listening js
Channel.php Route: Did you modify something manually in the "laravel-echo" repo? something wrong there??? Noted that I am using Sanctum CSRF authentication |
@anwardote the only problem possible is yout laravel-echo-server is still on version 2, that maybe it |
@xiCO2k can I force Laravel Echo to use |
@xiCO2k Yes probably. Can you share, how did you solve it? Or it would be more helpful if you could share a complete git repo for us. |
@anwardote I did fork it and upgrade that package, on my repo. |
@xiCO2k I can't see any commits by you on your fork; https://github.com/xiCO2k/echo/commits/master |
I have a fork of Laravel Echo Server that works with v3.0 and it's modified by a lot from the original fork, and it seems like the Bad Handshake error do not happen, however, I'm investigating the issue where the reconnection does not take place after abruptly losing the connection to the server: #295 |
We've decided we won't be investing time anymore into Socket.io since we don't maintain the laravel-echo-server package. Instead we recommend to use something like https://github.com/beyondcode/laravel-websockets. Sorry for this and thank you for understanding. |
Okay upadted larvel-echo-server with latest socket.io server since the vulnerability and it works perfectly : |
@LeGmask You can also check this project as an maintained alternative of Laravel Echo Server: https://github.com/soketi/echo-server |
@rennokki Oh that's nice, should be mentioned somewhere, since there nothing realiable to this ! |
@LeGmask I have tried to make it known on the Laravel Discord channel and I have also created an issue on the Laravel Echo Server board. It was initially forked from that repository and eventually migrated to Pusher REST API and a separate branch from the laravel/echo since it dropped support to Socket.IO. |
Use this package https://www.npmjs.com/package/laravel-echo-server-updated that is fork https://github.com/LeGmask/Laravel-Echo-Server and there is v4 socket.io server if need to fix cors errors after using updated package, add to laravel-echo-server.json config "socketio": {
"cors": {
"origin": "http://localhost:39558",
"methods": ["GET", "POST"],
"allowedHeaders": ["Origin", "Content-Type", "X-Auth-Token", "X-Requested-With", "Accept", "Authorization", "X-CSRF-TOKEN", "X-Socket-Id"],
"credentials": true
}
}, |
Not sure what to say, but if Echo does not plan to support Socket IO v3, you can as well just switch and migrate to Soketi pWS which is a standalone app that's compatible with the Pusher protocol. |
cloned repo with 4 version, and can't get it working with private channels. this |
So does Echo support Socket.io v4? |
hey @stratboy did it work for you? |
I didn't use it in the end. Anyway, I think Echo supports socket.io, but laravel echo server does not (package.json speaks) I think that probably currently the best js approach would be using https://docs.soketi.app/ |
Description:
After updating Socket.IO to v3.0.1 there are constant erros of
Bad handshake method
.{"code":2,"message":"Bad handshake method"}
The text was updated successfully, but these errors were encountered: