Describe the issue
First of all, great project! 馃憤
When client connected to a server, force exit the server and restart a new server, then the client seems to entered an infinity loop, it can never do a successful handshake with the new server, just keep reconnecting.
and when this happening, the client leak the NodeMessage for handshake as an message event, so I keep getting a handshake message on every reconnecting.
Code or steps to reproduce
Server:
import { Server } from 'veza';
async function main(): Promise<void> {
const name = 'my_server';
console.log('name', name);
const server = new Server(name);
await server.listen({
host: '127.0.0.1',
port: 11122,
});
setInterval(async () => {
console.log('broadcast!', server.sockets.size);
await server.broadcast({ hello: 'world' });
}, 2000);
}
main();
Client:
import { Client } from 'veza';
async function main(): Promise<void> {
const name = 'my_client';
console.log('name', name);
const client = new Client(name);
client.on('message', message => {
// Shouldn't get a handshake message in here.
console.log('message!', message);
message.reply({ world: 'hello' });
});
await client.connectTo({
host: '127.0.0.1',
port: 11122,
});
}
main();
- start server
- start client
ctrl+c stop the server
- restart server
Expected and actual behavior
- The client should reconnect with the new server
- The client's
message event should be emitted with a handshake message
Further details
Describe the issue
First of all, great project! 馃憤
When client connected to a server, force exit the server and restart a new server, then the client seems to entered an infinity loop, it can never do a successful handshake with the new server, just keep reconnecting.
and when this happening, the client leak the NodeMessage for handshake as an
messageevent, so I keep getting a handshake message on every reconnecting.Code or steps to reproduce
Server:
Client:
ctrl+cstop the serverExpected and actual behavior
messageevent should be emitted with a handshake messageFurther details