FIXED:SocketIO DAT reconnect

Hi, not sure if this is a bug or an RFE…

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 :slight_smile:

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!

1 Like

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.

1 Like

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);
    }
});

Adapted from this gist:

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.

1 Like

Great, thanks! Cool to hear about the delay being a param as well :+1:

@mattfelsen The currently posted build 2020.26630 has this fix. Wondering if it is working for you? Thanks!

1 Like

I’ll take a look and report back. Thanks!

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:

  1. killing the server
  2. turning the Active param off
  3. 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.

Thanks!

  1. killing the server

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.

  1. turning the Active param off

Thanks for the report – this didn’t work before either. Fixed.

  1. 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.

1 Like

Agreed on #3, I was trying whatever I could think of to trigger it since #1 wasn’t working.

This sounds great, feel free to ping me once the new build posts in case I miss it! Otherwise happy to test again once it’s up.

1 Like