hapijs / nes

WebSocket adapter plugin for hapi routes
Other
503 stars 87 forks source link

Client.onDisconnect is not called for some disconnections #217

Closed mtharrison closed 6 years ago

mtharrison commented 6 years ago

When the server side closes the connection, a Net.Socket error will be emitted, this causes nes to remove the ws.onclose handler and thus the client.onDisconnect handler will never be called. Example:

const Hapi = require('hapi');
const Nes = require('nes');

const server = new Hapi.Server({ port: 4000 });

const start = async () => {

    await server.register(Nes);
    await server.start();

    const client = new Nes.Client(server.info.uri);
    await client.connect();
    client.onDisconnect = () => { console.log('disconnected'); };

    await server.stop();
};

start();
mtharrison commented 6 years ago

This was fixed by #220

lock[bot] commented 4 years ago

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.