DJWoodZ / Satisfactory-Discord-Bot

A Discord bot that posts Satisfactory Dedicated Server status information such as online players.
MIT License
17 stars 3 forks source link

I no longer see it when people join the server #9

Closed Felix73739 closed 1 year ago

Felix73739 commented 1 year ago

The bot no longer shows when people join the server, I have now tried everything and nothing works.

do you have any ideas if you need information I can give it to you with pleasure. :)

DJWoodZ commented 1 year ago

Hi @Felix73739,

I'm sorry to hear you are experiencing this issue. As far as I'm aware, nothing has changed in the dedicated server to have caused this to happen, so I think we can rule that out but, to be sure, I've checked I'm running the latest version (211839) and the bot is working for me as expected. Therefore, I assume the issue lies with your installation or configuration.

The first thing thing to check would be that the Discord bot has the correct permissions to post in your server/channel. The bot itself needs the Send Messages permission (set via the Discord Developer Portal) and your server/channel permissions must also be set to allow the bot to post messages.

To rule out any corrupt files on your server, e.g. config or logs, I recommend stopping both the bot and the dedicated server processes. Then make sure you have the latest version of the bot and make sure no files have been modified. For example:

npm run pm2:stop
git checkout main
git pull
git status
git diff

Next check your .env.local file against the settings listed in the README.md to make sure they are specified/spelled correctly. If everything looks to be in order, start the dedicated server and the bot again, and watch the bot's log for any errors as it starts.

If there are no errors and bot is still not working when you try to join the game, double-check the dedicated server's log file is in the expected location. By default this is: /home/steam/SatisfactoryDedicatedServer/FactoryGame/Saved/Logs/FactoryGame.log. If the log file is in a different location you will need to make sure you've specified the correct path in your .env.local file using the SATISFACTORY_BOT_LOG_LOCATION variable. You should also check the file permissions to ensure the bot can read the file.

If the dedicated server's log file is present, try opening it to check nothing is obviously broken. Check the timestamps to make sure it is actually the current log. Note that the first line (Log file open) should list the time in the server's local timezone, but the main timestamps should be in UTC. You should also try tailing it to see if it shows the expected activity when you join a game. The main issues to check for are either obvious errors or no activity when you try to join.

I hope this helps you get to the bottom of the issue. Please let me know how you get on. Best of luck. 😃

Felix73739 commented 1 year ago

Thanks first for the quick answer,

The bot has the perms to send the messages to the channel because I also see the messages like that the server is online etc, so there everything is right :)

here is my .env.local file:

SATISFACTORY_BOT_DB_PATH=./db.json SATISFACTORY_BOT_DISABLE_UNREACHABLE_FOUND_MESSAGES=false SATISFACTORY_BOT_DISCORD_CHANNEL_NAME=server-stat SATISFACTORY_BOT_DISCORD_SERVER_NAME=Saves Server Satisfactory SATISFACTORY_BOT_DISCORD_TOKEN= SATISFACTORY_BOT_LOG_LOCATION=/home/steam/satisfactory/FactoryGame/Saved/Logs/FactoryGame.log SATISFACTORY_BOT_POLL_INTERVAL_MINUTES=1 SATISFACTORY_BOT_PURGE_DISCORD_CHANNEL_AFTER_DAYS=7 SATISFACTORY_BOT_PURGE_DISCORD_CHANNEL_AFTER_LINES= SATISFACTORY_BOT_PURGE_DISCORD_CHANNEL_HOUR=2 SATISFACTORY_BOT_PURGE_DISCORD_CHANNEL_NAME= SATISFACTORY_BOT_PURGE_DISCORD_CHANNEL_NAME= SATISFACTORY_BOT_SERVER_IP=127.0.0.1 SATISFACTORY_BOT_SERVER_MAX_PLAYERS=4 SATISFACTORY_BOT_SERVER_QUERY_PORT=15777 SATISFACTORY_BOT_SERVER_QUERY_TIMEOUT_MS=10000

I hope everything is correct there, I can't access the server right now because it is offline. I will do that later and then answer again if that is not a problem just wanted to have clarified that first.

if there are problems in the translation then ask with pleasure I'm just German and there can yes mistakes happen :)

Edit: it has shown at the beginning when users are joined only now after he is in autostart it no longer works.

is it perhaps because another of my bots the server only on command starts and not the server is in autostart or must I start the server earlier than the bot.

I look immediately in the logfiles and then I send everything conspicuous, but with which I can do nothing here.

Felix73739 commented 1 year ago

What is the name of the log file. Server is back on 😅

DJWoodZ commented 1 year ago

The Satisfactory Dedicated Server log file should be here: /home/steam/SatisfactoryDedicatedServer/FactoryGame/Saved/Logs/FactoryGame.log

The PM2 logs should be here: $HOME/.pm2/logs

I've just pushed a couple of changes to the branch linked to this issue to try to help with what could be happening.

The first change is a fix: When the bot process starts, it tries to read the Satisfactory Dedicated Server log file. This file should always exist, providing the server has run at least once before, unless it has been deleted, of course. If the file doesn't exist when the bot starts, the bot process would quit with an error. I do not think this was happening in your case but, just to be sure, I've added a fix for that. It will now wait for the log file to exist, rather than aborting with an error when the file is not found.

The second change is a new feature: Usually, the bot will not post to the Discord channel if it believes the server is offline. If you are trying to join the server after an auto-start and before the bot has had chance to poll the server, it could be that the bot thinks the server is in an 'unknown' or 'offline' state when you join, so it doesn't message the channel. The status that the bot believes the server is in is shown in the bot's activity status in Discord. If it believes the server is not online, it will say something like 'Playing unknown' or 'Playing offline'. To over-ride this behaviour and force the bot to send joined/left messages to the channel even if it believes the server is offline, I've added a SATISFACTORY_BOT_IGNORE_POLL_STATE_WHEN_MESSAGING option, which you can enable with:

SATISFACTORY_BOT_IGNORE_POLL_STATE_WHEN_MESSAGING=true

I have added a new dependency so, after pulling in the latest changes and switching to the 9-i-no-longer-see-it-when-people-join-the-server branch, you will need to run npm install. For example:

npm run pm2:stop
git pull
git checkout 9-i-no-longer-see-it-when-people-join-the-server
npm install

Then add this line to your `.env.local':

SATISFACTORY_BOT_IGNORE_POLL_STATE_WHEN_MESSAGING=true

And start the bot again:

npm run pm2:start

It'd be great if you could try the bot with these changes. I will do the same for a few days too, to make sure it continues to behave as expected.

I hope this helps to fix your issue. 🤞 🙂

Please let me know how you get on with these changes.

Felix73739 commented 1 year ago

The logs are in the folder i have in my .env.local but in the Bot Terminal output he shows Log file open 06/23/23 15:29:42 But my date is 06/25/23 and 09:41

Only errors in the Bot log are connection timed out because the Bot runs on the night the Server doesnt.

:man_shrugging: The server is unreachable. :thumbsup: The server has been found. :rocket: The server is back online! :rocket: Server version: 211839 Thats the bot when i start him and the server is on

i think there is everything okay and

markus@server15:/home/steam/satisfactory/FactoryGame/Saved/Logs$ ls -a . .. FactoryGame_2-CRC.log FactoryGame_2.log FactoryGame-CRC.log FactoryGame.log

that are my logs

ig that is the error: [2023.06.23-15.29.52:215][ 0]Log file closed, 06/23/23 15:29:52 in the Bottom of the logfile FactoryGame.log`

DJWoodZ commented 1 year ago

Is the issue still happening with the updates on the 9-i-no-longer-see-it-when-people-join-the-server branch?

Log file open 06/23/23 15:29:42 refers to when the Satisfactory Dedicated Server opened the log file, i.e. it is not the date that the bot accessed the log file, it is the date when the Satisfactory Dedicated Server created the log file. The bot uses this to determine when the Satisfactory Dedicated Server has been restarted, as it needs to reset the player counts back to zero when that happens.

The Satisfactory Dedicated Server should create a new log file every time the process is started, so that is suggesting your Satisfactory Dedicated Server process was last started 2 days ago.

To verify the bot is reading the expected file, the line shown in the bot's log should match the line in the Satisfactory Dedicated Server log file. This line should be the first line in any Satisfactory Dedicated Server log file.

Similarly, Log file closed, 06/23/23 15:29:52 refers to when the Satisfactory Dedicated Server closed the file (i.e. when the server process stopped). As the Satisfactory Dedicated Server should rotate the logs every time it starts (see Logs and crash dumps), this means FactoryGame.log should only contain Log file closed when the Satisfactory Dedicated Server is not running.

If your server is running and FactoryGame.log file contains Log file closed at the end, it suggests that the Satisfactory Dedicated Server is not rotating and writing to the log file. Can you verify whether that is what's happening?

If this is happening, I wonder if something is preventing the Satisfactory Dedicated Server from rotating the file. It could be something to do with file handles which causes this to happen, but I leave my Discord bot running and I stop and start Satisfactory Dedicated Server without issue, so I'm not sure why that would be the issue for you?

For example, if I kill the Satisfactory Dedicated Server process (but leave the Discord bot running) and start the Satisfactory Dedicated Server process again, the bot picks up the new log and carries on as expected:

2023-06-25T09:27:47: Updating...
2023-06-25T09:28:47: Updating...
2023-06-25T09:28:57: Sending message to: Discord server
2023-06-25T09:29:47: Updating...
2023-06-25T09:30:14: Log file open 06/25/23 09:30:14
2023-06-25T09:31:47: Updating...

To rule out other possible issues, as you mentioned this issue started recently, have you recently added any other processes (e.g. Discord bots) that also monitor the Satisfactory Dedicated Server log file? If so, maybe you could try disabling them to see if it fixes the issue.

Felix73739 commented 1 year ago

1st question yes markus@server15:/opt/SaveBot/SaveBotextendet/Satisfactory-Discord-Bot$ git checkout 9-i-no-longer-see-it-when-people-join-the-server Already on '9-i-no-longer-see-it-when-people-join-the-server' Your branch is up to date with 'origin/9-i-no-longer-see-it-when-people-join-the-server'.

2nd the Server is Running and the logfile shows [2023.06.23-15.29.52:215][ 0]Log file closed, 06/23/23 15:29:52

i don´t get it :( no other log is created the Bot logs in a File that is not existing.

3th i have no other bot that is monitoring the logfiles i have a Bot that picking up the save files and sending it to a channel on a command but i don´t think that is a problem.

short: The Server don´t make a new log file when it started also he is not replacing the old content out of the FactoryGame.log file i don´t know what the problem is here.

I start the server so:

i go in the Folder where the FactoryServer.sh is and do bash FactoryServer.sh and the server is booting i can join the server the bot recognized the server is on but didnt get the log because it is not existing.

NOTE!::

i have Fixxed it with your help i have read a little bit through the docs satisfactory dedicated Server thing and read the command:

bash FactroyServer.sh -log path/to/your/log/FactoryGame.log

when that is not working give rights in the directory for the logs using this:

sudo chown -R steamuser:steamuser directory

and that is it the Server writes in the log back again and it worked.

thank your smmm have a nice day!

DJWoodZ commented 1 year ago

Ah, great! I was just writing another reply. :smile:

I'm glad you got it working. :+1: Well done on finding the permission issue.