No Immortal Timeout

Posted by Whisperedecho on Mon 19 May 2008 02:54 AM — 27 posts, 88,817 views.

USA #0
I want to set it so that Immortals don't get timed out from the MUD.

I looked in comm.c and tried adding in an "IF" check but I keep getting compiler errors so I must be doing something wrong.

Can someone tell me what I would have to add in so that regular players would be timed out normally but Immortal characters can stay on until they manually disconnect or that they would have a separate timeout before they are disconnected? Thanks.
Amended on Mon 19 May 2008 04:42 AM by Whisperedecho
Australia Forum Administrator #1
It's always hard to help when you don't show us the code you tried, and you don't show us the error message you got.

Try searching the forum for "immortal timeout". I found this post:

http://www.gammon.com.au/forum/bbshowpost.php?id=2308

USA #2
I tried implementing the fix from the other post but I'm still getting disconnected.

This is the code I have:


else if ( ((!d->character && d->idle > 360)	/* 2 mins */
		   || ( d->connected != CON_PLAYING && d->idle > 1200) /* 5 mins */
		   || d->idle > 28800 )	/* 2 hrs */
		   /* allow imms to stay on indefinitely */
		   && (d->character && d->character->level < LEVEL_IMMORTAL)
  		     )
         {
            write_to_descriptor( d, "Idle timeout... disconnecting.\r\n", 0 );
            d->outtop = 0;
            close_socket( d, TRUE );
            continue;
Australia Forum Administrator #3
You haven't exactly done what is in the other post have you? The way you have done it, people who haven't given a character name will never get disconnected (ie. if d->character is NULL).

However I can't see why you would be disconnected if:

  • You have logged in; and
  • You are level LEVEL_IMMORTAL or higher


If that is the case, try firing up gdb, and put a breakpoint on the line where it says "Idle timeout... disconnecting." and see what the various fields are.
Australia Forum Administrator #4
I just want to point out too, that a little while ago you posted your amended fix, and then deleted that message for some reason (time on audit log 2008-05-23 01:32:16). The code you posted then was different to what you have above.

So is the code you posted recently what you actually have?

I prefer when people don't delete messages - even if they seem irrelevant now - because the fix you used can be helpful to other people, or to us, if it doesn't work perfectly.
Amended on Sat 24 May 2008 05:00 AM by Nick Gammon
Australia Forum Administrator #5
The reason I went to the audit log (which I don't usually do), is that I remembered this thread as being longer a day or so ago, and you posted some code that looked different to what I had in the other thread. It wasn't clear why you had to change it, or whether the new code would work or not. And then it just disappeared. And then you post a message about how it isn't working. It just all seems a bit strange.
USA #6
Hi Nick. The reason I deleted the other post was because I found that I was still being disconnected so it wasn't really a fix and I didn't want people using it if they thought it was a fix.

The reason the code looks different is because I've been playing around with it trying to get it to work and that is the most recent code that I have.
Australia Forum Administrator #7
Are you sure you are logged in as LEVEL_IMMORTAL? The default admin character with Smaug is level 65, but if you increased the level limit (say, to 100), then level 65 is not immortal.

If you are sure you are immortal level, try what I suggested to use gdb to find out why you are being disconnected. See:

http://mushclient.com/gdb
USA #8
I did increase the max_level to 115 but I made sure to increase my player file to adjust for that fact.

I believe Kayle on SmaugMUDS may have found an answer:

http://www.smaugmuds.org/index.php?a=topic&t=3722&p=15315#p15315
Australia Forum Administrator #9
Well I tried my suggested code from the other link, and I haven't been disconnected. You are doing something different. Let's check 3 major points. Please follow along and paste your results, like I am doing.

First - my admin level (type score):


score

Score for Admin the Attendant.
----------------------------------------------------------------------------
LEVEL: 65          Race : Elf               Played: 134 hours
YEARS: 17          Class: Druid             Log In: Mon May 26 10:36:58 2008
STR  : 10(10)    HitRoll: 1                 Saved:  no save this session
INT  : 15(14)    DamRoll: 0                 Time:   Mon May 26 10:37:02 2008


The immortal level from mud.h:


#define MAX_LEVEL                  65
#define MAX_CLAN                   50
#define MAX_DEITY                  50
#define MAX_CPD                     4 /* Maximum council power level difference */
#define MAX_HERB                   20
#define MAX_DISEASE                20
#define MAX_PERSONAL                5 /* Maximum personal skills */
#define MAX_WHERE_NAME             29
#define LEVEL_HERO                 (MAX_LEVEL - 15)
#define LEVEL_IMMORTAL             (MAX_LEVEL - 14)
#define LEVEL_SUPREME              MAX_LEVEL


The code change in comm.c:


        d->idle++;  /* make it so a descriptor can idle out */
         if( FD_ISSET( d->descriptor, &exc_set ) )
         {
            FD_CLR( d->descriptor, &in_set );
            FD_CLR( d->descriptor, &out_set );
            if( d->character && ( d->connected == CON_PLAYING || d->connected == CON_EDITING ) )
               save_char_obj( d->character );
            d->outtop = 0;
            close_socket( d, TRUE );
            continue;
         }
         else if( (( !d->character && d->idle > 360 )  /* 2 mins */
                  || ( d->connected != CON_PLAYING && d->idle > 1200 )  /* 5 mins */
                  || d->idle > 7200 ) /* 30 mins  */
                  /* allow imms to stay on indefinitely */
                  && !(d->character && d->character->level >= LEVEL_IMMORTAL)
                  )
         {
            write_to_descriptor( d, "Idle timeout... disconnecting.\r\n", 0 );
            d->outtop = 0;
            close_socket( d, TRUE );
            continue;
         }


I dropped down the idle time to 7200 to make testing a bit quicker.

Last question - do you actually see "Idle timeout... disconnecting."? If not, it could be your router disconnecting you.

USA #10
Admin Level:

Score for Lashiec the Implementor.
----------------------------------------------------------------------------
LEVEL: 115 Race : Elf Played: 85 hours
YEARS: 18 Class: Mage Log In: Sun May 25 22:25:58 2008
STR : 18(18) HitRoll: 89 Saved: no save this session
INT : 18(18) DamRoll: 69 Time: Sun May 25 22:26:04 2008
WIS : 18(18) Armor: -0325, that of an avatar
DEX : 18(18) Align: +1000, devout Items: 00000 (max 23000)
CON : 18(18) Pos'n: standing Weight: 00000 (max 1000000)
CHA : 18(18) Wimpy: 100 Fighting Style: standard
LCK : 18(18)
Glory: 5000(0000)
PRACT: 160 Hitpoints: 32700 of 32700 Pager: ( ) 999 AutoExit(X)
XP : 2000 Mana: 30000 of 30000 MKills: 00013 AutoLoot(X)
GOLD : 10,000,017 Move: 30000 of 30000 Mdeaths: 00000 AutoSac (X)
You feel great.
Languages: common elvish dwarven pixie ogre orcish trollese rodent insectoid mammal reptile dragon spiritual magical goblin god ancient halfling clan gith gnome
----------------------------------------------------------------------------
IMMORTAL DATA: Wizinvis [ ] Wizlevel (115)
Bamfin: Lashiec appears in a flash of blue light.
Bamfout: Lashiec leaves in a flash of blue light.
Vnums: Room (10500 - 10700) Object (10500 - 10700) Mob (10500 - 10700)
Area Loaded [no]

Immortal Level from mud.h:

#define MAX_LEVEL 115
#define MAX_CLAN 50
#define MAX_DEITY 50
#define MAX_CPD 4 /* Maximum council power level difference */
#define MAX_HERB 20
#define MAX_DISEASE 20
#define MAX_PERSONAL 5 /* Maximum personal skills */
#define MAX_WHERE_NAME 29
#define LEVEL_HERO (MAX_LEVEL - 15)
#define LEVEL_IMMORTAL (MAX_LEVEL - 14)
#define LEVEL_SUPREME MAX_LEVEL
#define LEVEL_INFINITE (MAX_LEVEL - 1)
#define LEVEL_ETERNAL (MAX_LEVEL - 2)
#define LEVEL_IMPLEMENTOR (MAX_LEVEL - 3)
#define LEVEL_SUB_IMPLEM (MAX_LEVEL - 4)
#define LEVEL_ASCENDANT (MAX_LEVEL - 5)
#define LEVEL_GREATER (MAX_LEVEL - 6)
#define LEVEL_GOD (MAX_LEVEL - 7)
#define LEVEL_LESSER (MAX_LEVEL - 8)
#define LEVEL_TRUEIMM (MAX_LEVEL - 9)
#define LEVEL_DEMI (MAX_LEVEL - 10)
#define LEVEL_SAVIOR (MAX_LEVEL - 11)
#define LEVEL_CREATOR (MAX_LEVEL - 12)
#define LEVEL_ACOLYTE (MAX_LEVEL - 13)
#define LEVEL_NEOPHYTE (MAX_LEVEL - 14)
#define LEVEL_AVATAR (MAX_LEVEL - 15)

Code change in comm.c:

for( d = first_descriptor; d; d = d_next )
{
if( d == d->next )
{
bug( "descriptor_loop: loop found & fixed" );
d->next = NULL;
}
d_next = d->next;

d->idle++; /* make it so a descriptor can idle out */
if( FD_ISSET( d->descriptor, &exc_set ) )
{
FD_CLR( d->descriptor, &in_set );
FD_CLR( d->descriptor, &out_set );
if( d->character && ( d->connected == CON_PLAYING || d->connected == CON_EDITING ) )
save_char_obj( d->character );
d->outtop = 0;
close_socket( d, TRUE );
continue;
}
else if( ( !d->character && d->idle > 360 ) /* 2 mins */
|| ( d->connected != CON_PLAYING && d->idle > 1200 && (d->character->level < LEVEL_IMMORTAL) ) /* 5 mins */
|| d->idle > 28800 && (d->character->level < LEVEL_IMMORTAL)) /* 2 hrs */

{
write_to_descriptor( d, "Idle timeout... disconnecting.\r\n", 0 );
d->outtop = 0;
close_socket( d, TRUE );
continue;
}

(I implemented a fix from Kayle...that is why the code looks different)

As for the last part I don't get the idle disconnect message. All I get is "The server has closed the connection" message from Mushclient. If it is indeed my router, how do I go about fixing it so it does not kick me off?

EDIT: Just to note, in the logs it says:

Read_from_descriptor: Connection reset by peer
Sun May 25 22:43:12 2008 :: Closing link to Lashiec.
Amended on Mon 26 May 2008 02:50 AM by Whisperedecho
Australia Forum Administrator #11
Hmmm, I don't see the message "Connection reset by peer" when I get timed out (eg. if I connect but don't log in). I am wondering if you are actually going through this code. If not, changing it won't achieve anything.

I suggest adding another line just after the line where you get disconnected:


write_to_descriptor( d, "Idle timeout... disconnecting.\r\n", 0 );
log_string( "Player timeout" );   // <<-- add this


Now when I tested that, not only did I see this in my client window:


Enter your character's name, or type new: Idle timeout... disconnecting.


I also saw this in the server log:


Mon May 26 12:58:08 2008 :: (Name Not Set) ready on port 4020.
Mon May 26 12:59:41 2008 :: Player timeout


This confirms it actually did the timeout code.

Now if you simply get disconnected after 2 hours with a message about "Connection reset by peer", then as I said in my previous post, it could be your router (or Windows even) that is set to disconnect a session after 2 hours' inactivity. So in that case it is your client end that is doing it, not the server.
USA #12
Yes, I have been going through the code. I even tried changing it around myself before going to the forums but I couldn't get anything to work. I will try doing what you suggested and report back.
Australia Forum Administrator #13
You haven't said whether or not you get the message "Idle timeout... disconnecting." in your client at the moment when you are disconnected. If not, I think looking through the code won't do much.

A Google search on: "Connection reset by peer" windows "2 hours"

gives quite a few results, I think that a 2-hour timeout for network inactivity is fairly common. I also think there is a fix in the Registry (can't remember what it is at present) that could remove the limit.

The other thing to do is simply configure your client to do something every hour or so (like send "sigh") which should be enough to keep the connection alive.
USA #14
Yes I did.....

(I implemented a fix from Kayle...that is why the code looks different)

As for the last part I don't get the idle disconnect message. All I get is "The server has closed the connection" message from Mushclient.

Usually I've noticed the connection gets kicked off around 10 minutes. I just got kicked off again:

32700hp 30000m 30000mv> <Room #1221>
--- Disconnected on Sunday, May 25, 2008, 11:15 PM ---
--- Connected for 0 days, 0 hours, 10 minutes, 1 second. ---

The "WhisperedEcho" server has closed the connection

I forgot to mention before that I am logged in when I am disconnected...I am just not doing anything.
Amended on Mon 26 May 2008 03:22 AM by Whisperedecho
Australia Forum Administrator #15
Quote:

Yes I did.....

(I implemented a fix from Kayle...that is why the code looks different)

As for the last part I don't get the idle disconnect message.


Your message read, when I read it:

Quote:

(I implemented a fix from Kayle...that is why the code looks different)

And I will check for that last part.


I hoped you would report in a fresh message the results of that investigation. I can't really be expected to scroll back and re-read old messages in the hope that maybe information in them will change.


OK, so you didn't get the idle disconnect message, so you aren't disconnected because of that code, so making changes to it will do nothing.

Quote:

Usually I've noticed the connection gets kicked off around 10 minutes. I just got kicked off again:


Why on earth didn't you mention that before? The code we are looking at has three time intervals in it:

  • 2 minutes if you haven't entered a character name
  • 5 minutes if you haven't started playing
  • 2 hours if you are playing but are idle


So, a 10 minute disconnect is none of those. Also, did you try logging in as a non-immortal? Like, level 1? Are you also disconnected after 10 minutes? If so, this is nothing to do with being immortal or not, or the code we have been poring over for the last day.
Amended on Mon 26 May 2008 03:33 AM by Nick Gammon
USA #16
Sorry, didn't realize that you had not seen that.

As for the 10 minutes thing, I thought it was related earlier to the disconnect as when I changed the values around it disconnected me after 30 seconds instead of 10 mins.

I will try my testcharacter (lvl 1) and see if it disconnects me after 10 minutes.
USA #17
Ok, it's been over 11 minutes now with my test character loaded into the game and no disconnect has happened.
Amended on Mon 26 May 2008 03:48 AM by Whisperedecho
USA #18
I was disconnected after 15 mins:

<30hp 110m 110mv>
Your surroundings begin to fade as a mystical swirling vortex of colors
envelops your body... When you come to, things are not as they were.

A strange voice says, 'We await your return, Testchar...'
--- Disconnected on Sunday, May 25, 2008, 11:48 PM ---
--- Connected for 0 days, 0 hours, 14 minutes, 59 seconds. ---

The "WhisperedEcho" server has closed the connection

Logs say: Sun May 25 23:48:40 2008 :: Testchar has quit (Room 1221)
Amended on Mon 26 May 2008 03:50 AM by Whisperedecho
Australia Forum Administrator #19
Well that looks like something else again. If you search for that message it is in do_quit, which is nothing to do with the idle timeout.

I suggest you add the line I mentioned before to comm.c:


log_string( "Player timeout" );   // <<-- add this


At least you will know for sure whether it is the idle timeout code that is responsible. I am starting to doubt it.
USA #20
Ok, I'll try that. I tried changing the code to see if it would timeout:

else if( ( !d->character && d->idle > [b]360[/b] ) /* 2 mins */
|| ( d->connected != CON_PLAYING && d->idle > 1200 && (d->character->level < LEVEL_IMMORTAL) ) /* 5 mins */
|| d->idle > 120 && (d->character->level < LEVEL_IMMORTAL)) /* 2 hrs */

but I am still connected after 5 mins so I also doubt it is that. I'll report back after I see if the fix from your previous post does the trick.
USA #21
I had already applied that fix in your post to the code but it is not showing up in the logs.

I am searching on Google for potential causes. I am using a Linksys router with Ubuntu.
Amended on Mon 26 May 2008 04:14 AM by Whisperedecho
Australia Forum Administrator #22
Can we clarify something? You said you don't get the message about "idle timeout ... disconnecting", but do you always get the message you showed a few posts ago? This one:


Your surroundings begin to fade as a mystical swirling vortex of colors
envelops your body... When you come to, things are not as they were.


If you have always got that message it would have been helpful to mention it (you haven't timed out, you have been forced to quit, that isn't the same thing). And if that is always the message we have been looking in the wrong spot.

There is a place in update.c which calls do_quit for some reason - I'm not totally sure why, but it is something to do with "if( ch->timer > 24 )" - whatever that means in this case.

Amended on Mon 26 May 2008 04:13 AM by Nick Gammon
USA #23
I only got that message after being connected with my level 1 character. I have never got that message when connected with my Immortal character.

The only message I get with my Immortal character is the sudden disconnect message and the "Connection reset by peer" message in the log.

When my test character was disconnected, it gave the message that you quoted from above and it said "Testchar quit" in the logs.
Amended on Mon 26 May 2008 04:16 AM by Whisperedecho
USA #24
Don't know if this will help you but one of my other Imms keeps getting disconnected as well and this is what I see when he is disconnected:


Comm: EOF encountered on read.
Comm: Closing link to Hawthorne.
Hawthorne has lost his link.
USA #25
Interesting....

I just got disconnected after being on for 15 and the other Imm got booted off at 10 mins.

I just uninstalled the firewall on my ubuntu machine...hopefully the problem is that simple to fix.

I'll keep you updated.
USA #26
Well, looks like the firewall was the problem. I've been connected for 20 minutes now with no problem

Thank you for all your help Nick and I'm sorry I wasted your time on a fool's errand. Fortunately (depending on how you look at it), it was a simple fix that I should have seen but at least I caught it instead of wasting more time on the problem.

EDIT: For anyone reading this post I was using lokkit as the firewall if you're curious. I didn't change any rules, just uninstalled it.