lukeed / sockette

The cutest little WebSocket wrapper! 🧦
MIT License
2.45k stars 81 forks source link

Put an option to always reconnect, no matter what #70

Open gigitalz opened 1 year ago

gigitalz commented 1 year ago

I had to undo the 1000,1001,1005 exceptions in the onClose method. Some reverse proxies like Caddy close the ws with 1001 if you stop/start them, it's so it's annoying having to refresh the page at each reboot or simply reverse proxy config change. Please add an option where you bypass the 1000,1001,1005 check, some application want to keep retrying no matter what.

onclose: e => {
  console.log(`Closed with code: ${e.code}`);
  if (e.code === 1e3 || e.code === 1001 || e.code === 1005) {
    this.ws.reconnect(e);
  }            
},