yairm210 / Unciv

Open-source Android/Desktop remake of Civ V
Mozilla Public License 2.0
8.44k stars 1.56k forks source link

UncivServer: Fail to create multiplayer game if MultiplayerFiles folder is not present #9697

Open nrader95 opened 1 year ago

nrader95 commented 1 year ago

Platform Linux x64

Version 4.7.4

Describe the bug When creating new game and selecting it as multiplayer one and adding another human player, it failed for me. The server log printed IO exception regarding contents in MultiplayerFiles folder. A folder i didnt have at all. Creating the folder manually solved the problem. So i think the problem is that game (or game server, i'm not sure which one of them) is not checking if path to the multiplayer files exists before working with it.

SomeTroglodyte commented 1 year ago

server log printed

If you can read it, why not also let us read it?

or game server, i'm not sure which

Well, I would not be sure which either. So, tell us more - what server, or more importantly - "Creating the folder manually" - local or serverside?

nrader95 commented 1 year ago

Well, I would not be sure which either. So, tell us more - what server, or more importantly - "Creating the folder manually" - local or serverside?

Right, sorry. It was in console output of the server. And local or server-side is the same for my as i run both game and server on same machine, and having both game and server .jar files in same folder, too.

Heres the error: [ERROR] Error while creating game | java.lang.Exception: Server returned HTTP response code: 500 for URL: http://localhost:8080/files/fd89aad5-ffa4-44ad-b49b-9833271e67ec at com.unciv.logic.multiplayer.storage.UncivServerFileStorage$saveFileData$1.invoke(UncivServerFileStorage.kt:20) at com.unciv.logic.multiplayer.storage.UncivServerFileStorage$saveFileData$1.invoke(UncivServerFileStorage.kt:14) at com.unciv.logic.multiplayer.storage.SimpleHttp.sendRequest(SimpleHttp.kt:69) at com.unciv.logic.multiplayer.storage.UncivServerFileStorage.saveFileData(UncivServerFileStorage.kt:14) at com.unciv.logic.multiplayer.storage.OnlineMultiplayerServer.tryUploadGame(OnlineMultiplayerServer.kt:105) at com.unciv.logic.multiplayer.OnlineMultiplayer.createGame(OnlineMultiplayer.kt:130) at com.unciv.ui.screens.newgamescreen.NewGameScreen$startNewGame$2.invokeSuspend(NewGameScreen.kt:327) at com.unciv.ui.screens.newgamescreen.NewGameScreen$startNewGame$2.invoke(NewGameScreen.kt) at com.unciv.ui.screens.newgamescreen.NewGameScreen$startNewGame$2.invoke(NewGameScreen.kt) at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:89) at kotlinx.coroutines.CoroutineScopeKt.coroutineScope(CoroutineScope.kt:264) at com.unciv.ui.screens.newgamescreen.NewGameScreen.startNewGame(NewGameScreen.kt:298) at com.unciv.ui.screens.newgamescreen.NewGameScreen.access$startNewGame(NewGameScreen.kt:53) at com.unciv.ui.screens.newgamescreen.NewGameScreen$onStartGameClicked$7.invokeSuspend(NewGameScreen.kt:232) at com.unciv.ui.screens.newgamescreen.NewGameScreen$onStartGameClicked$7.invoke(NewGameScreen.kt) at com.unciv.ui.screens.newgamescreen.NewGameScreen$onStartGameClicked$7.invoke(NewGameScreen.kt) at com.unciv.utils.ConcurrencyKt$launchCrashHandling$1.invokeSuspend(Concurrency.kt:87) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)

The weirs part is, if i specify server address in the game as http://localhost:8080 it worked But, if i change that to raw ip and port combo, like http://127.0.0.1:8080, it fails. (error above was for IP:Port combo despite mentioning the localhost alias) Creating the MultiplayerFiles folder manually while having server address specified as http://IP:Port works too.

SomeTroglodyte commented 1 year ago

"the server" - so you mean our soon-to-be-ditched UncivServer.jar - could have been any of the other existing reimplementations of the basic protocol. I wouldn't put too much weight on problems with that, I consider that thing obsolete or as good as. But - yes it's conceivable there might be some race condition if you have two processes competing for the same working directory contents... Actually, not weird but pretty obvious if you consider the client expects the server to be an external black box, and "external" means "my files are mine", too. Also - server is BS if you aren't gonna connect at least two clients. Now, if client 1 were allowed to share the server's data directory directly but client 2 not, that would be unfair, no?

Please do us a favour and scan the wiki whether there's really no hint that UncivServer shouldn't share a working directory with a client on the same box. And if there isn't, how about editing the wiki source yourself? Works via PR just like translating does. Explained somewhere in the wiki too.

:+1: And thanks for the input!

nrader95 commented 1 year ago

Well i just tried putting them separately, and the results were the same. So its not an issue related to them sharing the same folder.

SomeTroglodyte commented 1 year ago

Really? I mean they shouldn't share the same working folder - which depends on how you start the jar. A shell script wrapper would likely set it explicitly, just double-clicking might default to the jar's directory,....

nrader95 commented 1 year ago

I did move the .jar to different folder, opened terminal there to run it. So yeah. So server seems to be simply not checking if the MultiplayerFiles exists for some cases, and fails because of that.

github-actions[bot] commented 7 months ago

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 15 days.