| www.ClassicTW.com https://mail.black-squirrel.com/ |
|
| TW Keepalive https://mail.black-squirrel.com/viewtopic.php?f=14&t=31586 |
Page 1 of 1 |
| Author: | John Pritchett [ Wed May 18, 2011 10:54 pm ] |
| Post subject: | TW Keepalive |
I've been wanting to add some kind of keepalive feature to TW. I notice that when I leave a game sitting, even on my local machine, it often loses its connection without a graceful close on either the client or the server. When this happens, the connection still takes up a node on TWGS, and the TW process remains in memory until the inactivity timeout kicks in on TW and shuts it down. I have found that using a keepalive on TW can keep the connection active (though I've only let it run for about 16 hours so far). What I'm wondering is what, if anything, I could use as a keepalive packet without effecting any helpers, scripts or other clients. If I could guarantee that every connection was through Telnet, I could use the Telnet command IAC+NOP, and Telnet would strip it out and ignore it, guaranteeing that it wouldn't effect the player. But obviously I can't assume everyone is using Telnet. So the question is, can I use a Telnet command like this with helpers? Do helpers strip out Telnet commands (#255+COMMAND)? The other question I have is, since this sequence is only sent every 60 seconds of inactivity, would it impact helpers or scripts even if it's not stripped? It would never appear as part of a game data stream. It would never interrupt a string that a script is waiting for, for example. |
|
| Author: | John Pritchett [ Sat May 21, 2011 11:07 am ] |
| Post subject: | Re: TW Keepalive |
Ok, so I've gone ahead and activated this feature in the game since I didn't get any feedback against it. We'll see how it works in practice. If anyone has any problems at all with this on the beta, let me know and I'll adjust it or yank it as needed. |
|
| Author: | Cruncher [ Sat May 21, 2011 12:18 pm ] |
| Post subject: | Re: TW Keepalive |
I'm running the TWX KeepAlive now in HHT 2010. How do I "turn on" the beta keepalive? Or is that just a given in an unlimited time game? I would prefer this to be a player side turn on/off feature. I wouldn't want the keepalive running in a time limit game, unless I specifically told it to, for say a potty break. |
|
| Author: | Big D [ Sat May 21, 2011 12:42 pm ] |
| Post subject: | Re: TW Keepalive |
Invisible keep alive shouldn't effect any scripts. Mombot has a built in keep alive, so if you use mombot there's no need to run the keep alive script that comes with twx. |
|
| Author: | Kavanagh [ Sat May 21, 2011 2:20 pm ] |
| Post subject: | Re: TW Keepalive |
John Pritchett wrote: I've been wanting to add some kind of keepalive feature to TW. I am puzzled as to the need for this. Used be, we who wrote, had and used them, were sort of cheating, at a time when bandwidth was an issue and sysops naturally made provision. I'm sure that I am missing something. |
|
| Author: | John Pritchett [ Sat May 21, 2011 11:56 pm ] |
| Post subject: | Re: TW Keepalive |
I think there's some misunderstanding about what this is. It's meant to be a network keep-alive, not a TW keep-alive. When a script sends a command every 30 seconds or so, that's making TW think that the player is still active so that the player will never timeout do to inactivity. If TWGS sends a command to the client, it won't effect the inactivity timeout. TWGS could send keepalives while the client is inactive and eventually times out. The point of TWGS sending a keepalive is just to keep the connection active because for some reason connections are going dead on this server (and I assume others as well). I've been testing long, inactive connections on this server to see if this keepalive shows any improvement. Unfortunately, it doesn't keep the connection from dropping. But, there's a very important thing that it does do. If the connection goes dead, it's an ungraceful close of the socket, and neither the client nor the server gets notification of the drop. This means that TWGS keeps the node active and the game continues to run. The connection won't get cleared until either the client or the server attempts to send data. At that point, whichever attempted to send data discovers that the socket is dead and will close. So if TWGS is sending a keepalive every 60 seconds, then the longest that a dead connection will remain active is 60 seconds. Once TWGS attempts to send this keepalive, it'll detect the dropped connection and close the game and clear the node. |
|
| Author: | Cruncher [ Sun May 22, 2011 9:51 am ] |
| Post subject: | Re: TW Keepalive |
Very nice. So rather than calling this a keepalive, we can call it a clean exit from the game, they drop to the menu but stay connected to the server? And player timeout disconnects will still work if they aren't running scripts themselves to stay connected - TWX KeepAlive or Mombot. Am I understanding this correctly? |
|
| Author: | Micro [ Sun May 22, 2011 5:35 pm ] |
| Post subject: | Re: TW Keepalive |
It would probably be better to call it an "Are You There". It allows the server to release the resources of a dropped connection without waiting 5 minutes for the session to time out. Back in the Dial-Up days, it was considered extremely rude for a player to drop carrier like that. |
|
| Author: | ElderProphet [ Sun May 22, 2011 8:32 pm ] |
| Post subject: | Re: TW Keepalive |
I don't foresee any problem JP, but as MicroBlaster mentioned, the Telnet command Are You There (#255 #246 I believe, or maybe #255 #253 #246) seems like the logical choice for this test. And if memory serves, TWGS already implements this command elsewhere, upon connection I think. |
|
| Author: | John Pritchett [ Sun May 22, 2011 10:43 pm ] |
| Post subject: | Re: TW Keepalive |
It was intended to be a keepalive in the same sense as the sockets keepalive: "An application can request that a TCP/IP provider enable the use of "keep-alive" packets on TCP connections by turning on the SO_KEEPALIVE socket option." That option didn't show any improvement in keeping connections alive (maybe because it's not a requirement on all sockets implementations). But yeah, since the "keepalive" I added also fails to keep the connection alive, and only serves to trigger an error and graceful close, you're right, it really is more of an "are you there" function at this point. As far as which commands to send, I think I'll stick with IAC+NOP for now, because that doesn't illicit a response in a telnet client. IAC+YATHERE expects a response which I'd then have to filter out to avoid resetting the TW inactivity timeout. This has been active on the server for several days now and I haven't had any complaints. |
|
| Author: | Trivius [ Thu Jun 02, 2011 10:36 pm ] |
| Post subject: | Re: TW Keepalive |
For additional consumption would it be practical to instead or in addition send queuing messages such as locally (at the TWGS) by running a listener that resets upon the receipt of new packages and if after exceeding 60-secionds queues a: “Connection idling detected…” and thereafter giving a series of shutting down messages, e.g., “Connection closing in x-minutes due to idling…”; as this would greatly aid scripting, such as when a script stalls out due to whatever reason. Also what about including an internal process when connections are forced closed locally on the TWGS (or when the TWGS application itself detects a shutdown/critical error) that would sent a dialog to the players warning that the game will be closing in the next 30-seconds or 1-minute (thus giving them a bit of time to find a safer place instead just closing down or having it as an option for the server operator to send out 2/5-minutes warnings), for example? |
|
| Page 1 of 1 | All times are UTC - 5 hours |
| Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |
|