alta-vr / js-tale

GNU General Public License v3.0
2 stars 10 forks source link

Bot connects to server with every status change #11

Closed mdingena closed 3 years ago

mdingena commented 3 years ago

Observed behaviour

Every time the server status changes, js-tale seems to establish a new connection. I think this is not intentional behaviour, and it might be the root cause of some other issues I've been having.

Here's a dump of my logs. I've filtered it down to one specific server (my bot is connected to many different game servers at the same time).

7/1/2021, 12:34:03 AM - [Server] A Timeship Tale received status. Online: true. Players: 15
7/1/2021, 12:34:03 AM - [ServerConnection] Doing initialize
7/1/2021, 12:34:03 AM - [ServerConnection] Connecting to A Timeship Tale
Connecting to 34.223.108.179:7394
Resolving connection!
Connection Succeeded, Authenticated as: 1529569283 - voodoo mod

7/1/2021, 12:34:28 AM - [Server] A Timeship Tale received status. Online: true. Players: 16
7/1/2021, 12:34:28 AM - [ServerConnection] Doing initialize
7/1/2021, 12:34:28 AM - [ServerConnection] Connecting to A Timeship Tale
Connecting to 34.223.108.179:7394
Resolving connection!
Connection Succeeded, Authenticated as: 1529569283 - voodoo mod

7/1/2021, 12:36:07 AM - [Server] A Timeship Tale received status. Online: true. Players: 17
7/1/2021, 12:36:07 AM - [ServerConnection] Doing initialize
7/1/2021, 12:36:07 AM - [ServerConnection] Connecting to A Timeship Tale
Connecting to 34.223.108.179:7394
Resolving connection!
Connection Succeeded, Authenticated as: 1529569283 - voodoo mod

7/1/2021, 12:37:25 AM - [Server] A Timeship Tale received status. Online: true. Players: 16
7/1/2021, 12:37:25 AM - [ServerConnection] Doing initialize
7/1/2021, 12:37:25 AM - [ServerConnection] Connecting to A Timeship Tale
Connecting to 34.223.108.179:7394
7/1/2021, 12:37:25 AM - [Server] A Timeship Tale received status. Online: true. Players: 15
Resolving connection!
Connection Succeeded, Authenticated as: 1529569283 - voodoo mod

7/1/2021, 12:40:09 AM - [Server] A Timeship Tale received status. Online: true. Players: 16
7/1/2021, 12:40:09 AM - [ServerConnection] Doing initialize
7/1/2021, 12:40:09 AM - [ServerConnection] Connecting to A Timeship Tale
Connecting to 34.223.108.179:7394
Resolving connection!
Connection Succeeded, Authenticated as: 1529569283 - voodoo mod

7/1/2021, 12:42:45 AM - [Server] A Timeship Tale received status. Online: true. Players: 17
7/1/2021, 12:42:45 AM - [ServerConnection] Doing initialize
7/1/2021, 12:42:45 AM - [ServerConnection] Connecting to A Timeship Tale
Connecting to 34.223.108.179:7394
Resolving connection!
Connection Succeeded, Authenticated as: 1529569283 - voodoo mod

⚠️ Important to note is that the connection.server.on('update', ...) event does not seems to fire inside the groupManager.automaticConsole connection handler. Judging by the output above, js-tale is capable of detecting server status updates, but it does not pass these events through to the server connection event handlers.

Expected behaviour

The bot should establish a server connection once and maintain that connection for the duration of the server's uptime. All server status updates should then be handled inside the automatic console connection's event handlers.

Narmdo commented 3 years ago

Absolutely not intentional.

By intention it should be attempting a connection on status change if there isn't already one.

In the future, it would be good to add another condition to that, of and has console permission to avoid spamming the API with requests that will only be rejected.

Will accept a PR if you find the issue, otherwise will try and track it down after I've finished with my cleanup_01 branch.

mdingena commented 3 years ago

This appears to be resolved in v2.0.0-rc.4.