I recently discovered the the SocketIO DAT, at least as of 99 2019.37030, doesn’t automatically reconnect when disconnected. While the docs don’t say that it should, the TCP/IP DAT does this so I figured that expecting parity was reasonable
I tested the callbacks and the onClose() method reliably gets called so I was able to implement it manually for my project. However I wanted to mention the state of the functionality, and get an idea of whether this is considered a bug or if it’s actually an RFE to either implement, expose a reconnect option as a toggle, and possibly also the reconnect interval as well. Thanks!
Hi @mattfelsen, could you try the 2020.20k official builds. 2019.37030 was the previous experimental from last year and a) it was the first experimental build with the most bugs b) the SocketIO DAT was new and it has a year of improvements now.
If you have a file or can reproduce it in 2020.25380, let us know.
Hi Ben. I just tried on 2020.23680 experimental and 2020.25380 official and I’m seeing the same behavior. Clicking the reset button works, but killing & restarting the server doesn’t result in the client reconnecting.
The server I’m using is super minimal:
// test-io-server.js
// Create the socket server
const PORT = 3000;
var socket = require('socket.io')(PORT);
socket.on('connection', function(client) {
console.log('Client connected')
// Listen for test and disconnect events
client.on('disconnect', onDisconnect);
// Handle a disconnection from the client
function onDisconnect() {
console.log('Received: disconnect event from client: ' + client.id);
client.removeListener('disconnect', onDisconnect);
}
});
Thanks for the report. This will be fixed in the next official release. I’ve also added a Reconnect Delay parameter to specify the time between reconnect attempts.
Hi Ben & Eric. I just tested and have mixed results to report.
The good is that the reconnect & delay param seem to work as expected. Nice! I tested this by simply killing (ctrl+C) and restarting a node.js app which hosts the socket.io server.
The bad is that onClose() callback doesn’t seem to get called anymore. I tried:
killing the server
turning the Active param off
deleting the node
1 used to cause onClose() to fire, so that seems like a regression. 2 & 3 don’t seem like they have much use, but just wanted to be thorough.
Ah, okay – we triggered the onClose from a callback on the socket.io side, but it looks like that’s not triggered while attempting to reconnect. I’ve fixed this.
turning the Active param off
Thanks for the report – this didn’t work before either. Fixed.
deleting the node
I don’t think it makes sense to trigger the onClose callback in this case since it passes the dat python object to the callback as a parameter, which would be invalid.