Skip to content
This repository has been archived by the owner on Sep 10, 2024. It is now read-only.

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant