doge/dayzservlet

Changes won't commit to MongoDB instance

doctashay opened this issue · 6 comments

I am currently attempting to use this servlet on DayZ 0.44.123800. I want to start by hosting the database locally to ensure save functionality so I've installed MongoDB and have the daemon running. I connect to it with MongoDB Compass and create a "dayz" database, and "players" collection. I configure my credentials in config.py and start the server with server.py. It is then specified in my init.sqf as http://localhost:5000/DayZServlet

The Python server is listening to and detects API calls from the game. The MongoDB instance detects a new connection from CPython when I launch the save server. When the game server attempts to save, the save server will report "Saved player" for that UID. The next intended behavior would be for it to find my character and retrieve it from the database, however, after disconnecting (which triggers another save) and reconnecting, the console message I receive is "player not found" for my particular UID. It appears that everything is working except the data is not being committed to my MongoDB instance.

How does this servlet currently know how to store variables such as pos_x, items, etc? I don't see any of these entries being referenced in this repository. Am I missing a piece of the puzzle?

I've tried this on clean copies of DayZ 0.44, 0.45, and 0.46 (the version you had tested) and all of them produce the same result, so I don't believe there's anything wrong with my mission files. If there's any other info I can provide to get this issue resolved please let me know and I appreciate any assistance you might have to offer

doge commented

The game sends post requests with data to the endpoints and the program stores exactly what the game sends it. That's very odd yours isn't saving on reconnect. Are you sure your MongoDB instance is setup correctly? I just tried it and it seems to be working fine.

image
image

Possibly there's a problem with your MongoDB user permissions if you're using a user/pass to connect? Also note, if you do fill in the username variable you must set username to True in config.py.

Currently am connecting with no user or pass so username is set to False.

I am noticing that I'm not receiving the "Creating player..." message that you do in you screenshot. I'm not at home currently but here's some old output I have saved.

Is there a reason the create request wouldn't be sending properly? Thanks

[2022-02-14 12:39:11] [76561197961360892] [/lud0/save/] Saved player.
[2022-02-14 12:39:18] [76561197961360892] [/lud0/save/] Saved player.
[2022-02-14 12:39:23] [76561197961360892] [/lud0/find/] Player not found.
[2022-02-14 12:39:24] [76561197961360892] [/lud0/find/] Player not found.
[2022-02-14 12:41:11] [76561197961360892] [/lud0/save/] Saved player.
[2022-02-14 12:43:11] [76561197961360892] [/lud0/save/] Saved player.
[2022-02-14 12:45:11] [76561197961360892] [/lud0/save/] Saved player.
[2022-02-14 12:46:06] [76561197961360892] [/lud0/save/] Saved player. ```

I was taking a look at my mission file and notice while I'm selecting a host, dbSelectHost is called, but dbCreateCharacter isn't.

In the game's source, there's this function here:
XX(GameBool, "dbCreateCharacter", DBCreateCharacter, GameString, "playerUID", "Creates new character record in database.", "_bool = DBCreateCharacter uid", "", "101171 DayZ", "", Category) \

I don't see this function being called anywhere in my mission or game. Would you mind checking the same thing on your end, to verify if your mission is potentially calling this command somewhere mine isn't? Back in 2015 when I setup a private server I don't recall ever having to use the dbCreateCharacter function or declare it anywhere, but it seems to be a likely cause of why the game isn't actually creating any data for the DB to commit. Cheers and thanks again

doge commented

You most likely have an issue with the mission file you're using. I'm unable to provide support for questions that are unrelated to the repository. Due to the nature of the content, I cannot re-upload my server files, but please look around for version 0.46.124490 as that's the version I've tested.

Understood, although as far as I am aware, there are no server files for 0.46.124490, and any server files that exist come from 0.28-0.45 with spoofed version numbers to prevent rejected connections. The server files you are using are very likely based on 0.42-0.45. I understand due to the nature of the content we can't share or distribute that information here, but can you verify whether or not there is a call to dbCreateCharacter either in your server files or PBO files, and if so, what file it would be present in?

For whatever reason in my mission file there was no call to dbCreateCharacter, for the clientNew event handler I added the following code:

_uid = getClientUID _id;
res1 = dbCreateCharacter _uid;

This solved my problem and now we are creating the player correctly. Thanks for your help