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

Client connected but it doesn't receive anything #4

Closed
pagoru opened this issue Sep 27, 2022 · 4 comments
Closed

Client connected but it doesn't receive anything #4

pagoru opened this issue Sep 27, 2022 · 4 comments
Labels
bug Something isn't working
Milestone

Comments

@pagoru
Copy link

pagoru commented Sep 27, 2022

The client is connected fine and can send and receive events, but some times the server doesn't recieve any event and the client is still connected.

The way to reproduce it:
Start and stop the client a few times, until it stops receiveing the pong message.

client:

const socket = io("http://localhost:8080");

socket.on("pong", ({ datetime }) => {
    console.log(`Response time (${(Date.now() - datetime)}ms)`)
});

socket.on("connect", () => {
    console.log(`Connected! ${socket.id}`);
    
    setInterval(() => {
        socket.emit('ping', { datetime: Date.now() });
    }, 1000);
});

socket.connect();

server:

const io = new Server();

io.on("connection", (socket) => {
    console.log(`socket ${socket.id} connected`);
    
    socket.on('ping', (data) => {
        console.log(`[${socket.id}]: ping!`)
        socket.emit('pong', data)
    });
});

await serve(io.handler(), {
    port: 8080,
});
@pagoru
Copy link
Author

pagoru commented Sep 27, 2022

Woooow, only two weeks from the start?? Great job, dude!

@darrachequesne
Copy link
Member

Hi! I could indeed reproduce the issue, I'm investigating.

@darrachequesne darrachequesne added the bug Something isn't working label Oct 10, 2022
darrachequesne added a commit that referenced this issue Oct 10, 2022
Before that change, the client was stuck waiting for the ongoing HTTP
long-polling request to be cleanly closed by the server, and the
upgrade process would fail after the 10s delay.

Note: the Node.js client implementation does not resume polling
("unpause") in that case, which looks like a bug.

Related:

- #4
- socketio/engine.io@00f9738
- socketio/engine.io@1c96ca4
- https://github.com/socketio/engine.io-client/blob/dfee8ded722a8c4f9f773505d0c77b4561569863/lib/transports/polling.ts#L84-L116
@darrachequesne
Copy link
Member

This should be fixed by c706741, included in 0.2.0.

Good catch, thanks!

@darrachequesne darrachequesne added this to the 0.2.0 milestone Oct 10, 2022
@sonickseven
Copy link

sonickseven commented Apr 27, 2023

@pagoru can you share your full code from client to connect, I'm trying to connect, but never I have fabled connect :(

How do you get variable "io"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants