Skip to content
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 client not work with Websockets implementation out of box #545

Open
Forsakenrox opened this issue May 28, 2023 · 0 comments
Open

Comments

@Forsakenrox
Copy link

Forsakenrox commented May 28, 2023

Need update wiki with worked examples, but the problem with websockets is more complex. and even this not help because core protocol of socket.io implemented wrong way. Ping\Pong also not working. The feeling that the implementation of web sockets in this package was abandoned on the half way.

Updated:
So, expirience way i found that this websocket implementation work only with socket.io-client version 2.

That what you need to do on the fronted side:

npm i socket.io-client@v2-latest

After that use this code for starting point:

import io from "socket.io-client";
const socket = io("ws://127.0.0.1:1215", {
        // transports: ["websocket"], //if you want force ws: connection instead of initial http:
    });
socket.on("connect", function (event) {
    console.log(event);
});
function handleClick() {
    socket.emit("hello", { text: "i say hey" });
}

I hope this help for anyone.
But anyway - wiki must be updated or laravel-swoole package must be updated to actual state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant