Bug - Fixed Switching server after login attempt

lostcalpolydude

Developer
Staff member
Validating login server (www4.kingdomofloathing.com)...
Redirected to www3.kingdomofloathing.com...
7 players online.
Sending login request...
Choosing new login server (www.kingdomofloathing.com)...
Encountered error in login.

Switching servers after trying to log in doesn't seem right. After this, I tried logging in without mafia and saw the expected "wait 5 minutes" message. I'm pretty sure I've seen this before, and I think I only see it shortly after rollover.
 
Last edited by a moderator:
I see this rather often immediately after rollover. I'm pretty sure what's happening is that mafia is timing out because it's not getting a response from the server, even though it sent the request, and the request went through, the server is just bogged down with requests right after rollover.

Usually what I do to fix it is just wait until like 5 or so minutes after rollover finishes to log in (if the number of players logged in is over 500 or so, that's a good cue).

So then, mafia doesn't realize that it's right after rollover and is just taking more time than usual, so it does what it would do if it were trying to hit a server at any other time and the server were not responding, and switches servers.

I would suggest that in the code, it should try to detect if rollover just ended (maybe if players logged in is less than 500, or check time-of-day?) and give it more slack than usual. I think? mafia waits 30 seconds before switching. If it could be made to wait like.. say.. 2 minutes, right after rollover, that might be better.
 

Veracity

Developer
Staff member
It only tries to choose a new login server if it got an I/O error on the login request. The only "expected" I/O error is a socket timeout, which it only detects if you have "allowSocketTimeout" as true. (Personally, I have that set to false, but I see that it is true by default. I don't want KoLmafia to timeout and retry connections, since HTTP is built on top of TCP connections, and those should retry just fine on their own.)

The current timeout - for all requests, including login requests - is 24 seconds. The third party code we use to get a timeout-equipped HTML connection is a bit messy in that the "current timeout" is a static - not per connection - but we'll only have a single connection pending during login. I should be able to increase the timeout just for logins.
 

Veracity

Developer
Staff member
OK, Revision 8270 does RT's suggestion: if players online is less than 500, we set the timeout for the login request to 2 minutes, rather than 24 seconds. Subsequent requests - fetching inventory and such - will use the normal 24 second timeout, regardless of time of day.
 
Top