midspace / Space-Engineers-Admin-script-mod

Modding script for Space Engineers with dozens of Admin commands for creating game scenarios or supporting servers.
43 stars 13 forks source link

Server crashes #71

Closed midspace closed 9 years ago

midspace commented 9 years ago

As noted by SiliconPot in the Steam workshop comments.

Exception occured: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.

at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at midspace.adminscripts.ConnectionHelper.ProcessServerData(String dataString)
at Sandbox.ModAPI.MyModAPIHelper.MyMultiplayerSyncObject.ModMessageRecieved(CustomModMsg& msg, MyNetworkClient sender)
at Sandbox.Game.Multiplayer.MySyncLayer.MyCallbackBase`1.Handle(TMsg& msg, UInt64 sender, TimeSpan timestamp)
midspace commented 9 years ago

Log files http://forum.keenswh.com/threads/the-game-crashes-when-try-to-access-the-server.7365559/#post-1286811148

midspace commented 9 years ago

Additional from DJ Arghlex. Believes it might be a read/write problem in the server's folder.

"Permission: Loading permission... Please try again later." http://arghlex.net/u/6JKMokw4lG.png

Spcemarine commented 9 years ago

It appears that these errors are unrelated. For the first two I have, at least, attempts to fix them but since I'm not able to reproduce them it is a little difficult to figure out what is wrong. For the last one with the permissions I don't really have an idea why it occurs. Generally it means that the client wasn't able to receive it's level from the server. The level is sent with the response to the connection request so in conclusion the request wasn't processed and I can't really imagine that because there would have been an exception if that was the case. Basically that's why I don't have a clue what is wrong with this, but at least it does not crash the server or the client. However, I'm going to make the client request it's permissions if it didn't receive it after a certain time is up.

midspace commented 9 years ago

You just beat me to my check in. I'm going through the changes now. :(

midspace commented 9 years ago
  1. I've added additional logging for the ProcessServerData and split the exception handling, in case there is an Action crash, and not a deserialize fault.
  2. I reproduced the "Permission: Loading permission... " momentarily when the I fouled up the deserialize in ProcessServerData. The two seem related, and may be due more to bad or old data.
  3. I'm not sure what went wrong here, but I'm I think it may be more due to the server still running an older version of the Mod and the server hasn't updated yet, causing the Client with the newer mod to crash inappropriate data. Exception occured: System.InvalidOperationException: There was an error reflecting type 'midspace.adminscripts.Messages.MessageContainer'. ---> System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.

I'm wondering if we should add a Version to the MessageBase or the content, and we update when I upload a new release, that way if a Client connects with a new version, the Server and Admin can be informed, or at least ignore the message.

midspace commented 9 years ago

That matches with the error that Vitold is getting. Ah, going to have to remote into home to download and fix. (at work currently.)

2015-08-03 21:30:59.433 - Thread: 1 -> Exception occured: System.InvalidOperationException: There was an error reflecting field 'Content'. ---> System.InvalidOperationException: There was an error reflecting type 'midspace.adminscripts.Messages.MessageBase'. ---> System.InvalidOperationException: There was an error reflecting type 'midspace.adminscripts.Messages.MessageAdminNotification'. ---> System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.

midspace commented 9 years ago

Have updated on Steam.

zrisher commented 9 years ago

Similar issue reported by some people joining my server:

zrisher commented 9 years ago

For most clients it doesnt matter if they mod isn't working properly for them, it's far more important they be able to join the game than have this functionality. Could you wrap the logic that's raising these issues in a try-catch?

midspace commented 9 years ago

zrisher we've literally just updated it 17 minutes ago, so please restart the server and try it again. We have added additional logging and exception handling to address these issues.

zrisher commented 9 years ago

Yep I saw that, we just restarted to try to fix so I'm going to give it a bit, will do later tonight. Either way, this does seem like another area that needs a try-catch.

midspace commented 9 years ago

Are either of you able to test MOTD and see if that still works as expected? If there is any failure in the messaging then use of the MOTD should show it.

zrisher commented 9 years ago

I can confirm that people who were able to join the server without issues could see the MOTD as well. But no idea for those who had problems, the game crashed before they were able to join.

I just restarted, the people having issues will give it a go again tomorrow.

midspace commented 9 years ago

I believe we've fixed all the crash issues now. I've left this issue open to improve the code I checked in.

zrisher commented 9 years ago

The same client above is still getting a crash when loading into the game (after hitting spawn screen, before final loading is complete): http://pastebin.com/5JkGAV1e

Both he and the server are running release.

Looks like serialization issues on client in AdminNotification (not an admin so not sure why he'd be getting one of those).

It looks like ChatCommandLogic.UpdateBeforeSimulation() does not use a try-catch. If it's too expensive to implement there, could we at least have it in the Init, Update10, and Update100 methods it calls? It would be unfortunate if his commands didn't work, but it's a much bigger issue that he can't join the game at all without it crashing.

midspace commented 9 years ago

It looks like AdminNotification is throwing exception on serilize. Will need to have a look at the ProtoBuf attributes on it.

midspace commented 9 years ago

Have updated the Admin mod. Please tell me we've nailed the issues.

zrisher commented 9 years ago

Thank you, waiting for a good time for a restart probably a few hours, will let you know.

midspace commented 9 years ago

Something has gone wrong, so I've rolled back the update. I've pushed the latest code to my Beta mod for further testing before releasing again. http://steamcommunity.com/sharedfiles/filedetails/?id=387257948

I've had one user give me the following, which seems strange as the the Timer I've clearly patched:

2015-08-06 02:03:46.465 - Thread:   1 ->  Player entered: Digi (76561197985528887)
2015-08-06 02:03:50.743 - Thread:   1 ->  World request received: Digi
2015-08-06 02:03:50.745 - Thread:   1 ->  ...responding
2015-08-06 02:04:04.531 - Thread:   1 ->  Exception occured: System.ArgumentException: Invalid value '0' for parameter 'interval'.
   at System.Timers.Timer..ctor(Double interval)
   at midspace.adminscripts.ServerConfig..ctor(List`1 commands)
   at midspace.adminscripts.ChatCommandLogic.InitServer()
   at midspace.adminscripts.ChatCommandLogic.UpdateBeforeSimulation()
   at Sandbox.Game.World.MySession.UpdateComponents()
   at Sandbox.Game.World.MySession.Update(MyTimeSpan updateTime)
   at Sandbox.MySandboxGame.Update()
midspace commented 9 years ago

I want to cry. It looks like I had partially merged code in my main branch when I brought in SpaceMarine's changes and then published to Steam. Space Engineers would have no doubt said the mod was broken and not loaded it. Hence the comment "no errors, just not working"

zrisher commented 9 years ago

Ah that sucks, did you have your changes backed up on another branch by chance?

Can confirm same error right now. Even without fixing this, if you could just wrap ChatCommandLogic.Init in a try-catch I could stop bothering you for an extended period of time : )

midspace commented 9 years ago

I do have the code in my personal branch (I call it a branch, but it's just a directory that I sync with Beyond Compare, as it's easier to migrate only the changes I need).

Which code? Git, Workshop 316190120, or 387257948 ?

I rolledback the public mod 316190120 (and re-fixed the Timer()), so that should be right. I've updated Git, but haven't tested it as yet. I can't at work.

zrisher commented 9 years ago

316190120

midspace commented 9 years ago

387257948 midspace Beta has been updated for testing. I'd like to make sure this one isn't broken before I release to the public mod this time.

I want to release this in about 12 hours just after the next SE update.

zrisher commented 9 years ago

It looks like your prod release 316190120 is more up to date, I'd prefer to test using that and your Timer fix (might be related), does that include your fix for the above? I don't see a separate branch relating to your dev code.

midspace commented 9 years ago

It was released almost 5 hours ago. There are no comments on Steam so far.

zrisher commented 9 years ago

Updated 316190120, that player will attempt connecting tomorrow.

zrisher commented 9 years ago

FIXED! Thank you!!!!

midspace commented 9 years ago

No further comments or complaints have been received about this, so I'm closing this issue.