MCCTeam / Minecraft-Console-Client

Lightweight console for Minecraft chat and automated scripts
https://mccteam.github.io
Other
1.68k stars 402 forks source link

Sharing violation - Chatlog #1484

Closed xXjojaXx closed 2 years ago

xXjojaXx commented 3 years ago

Every few hours the bot keeps spamming Errors in the cinsole which say (shortened): Sharing violation on path [path of chatlog] at MCC.Chatbot. ChatLog

In my understanding that would mean that another program tries to use the same file on the same time or something about similar. But I dont think there is so it must have to do with a problen coming from MCC. Do you know what is wrong? Thanks

ReinforceZwei commented 3 years ago

Please provide the full stack trace (error log) and the script you are using.

ORelio commented 3 years ago

The ChatLog bot currently does not handle concurrency so if you are running multiple instances of MCC on the same log file, it might break with the exception you are describing.

xXjojaXx commented 3 years ago

Thats very mystical because the name of the chatlogfile contains %username% and %server% and it shouldnt be possible that the same user is on the same server at the same time, I think.

ORelio commented 3 years ago

I think it would be clearer if you could post the whole error message with full stack trace just to make sure.

xXjojaXx commented 3 years ago

For some reason it stopped popping up for some days since I wrote the last post. But now it's back again and this is the warning and ther error message which are appearing many times in a row when the error occurs:

17:29:01 [ERROR] OnTextReceived: Got error from MinecraftClient.ChatBots.ChatLog: System.IO.IOException: Sharing violation on path /root/Minecraft/chatlog-MinecraftName-ServerAdress.txt at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x0019e] in <533173d24dae460899d2b10975534bb0>:0 at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode) [0x00000] in <533173d24dae460899d2b10975534bb0>:0 at (wrapper remoting-invoke-with-check) System.IO.FileStream..ctor(string,System.IO.FileMode) at MinecraftClient.ChatBots.ChatLog.save (System.String tosave) [0x0003d] in <0401b4e711114db0a8c3f277e178e060>:0 at MinecraftClient.ChatBots.ChatLog.GetText (System.String text) [0x00080] in <0401b4e711114db0a8c3f277e178e060>:0 at MinecraftClient.McClient+<>c__DisplayClass132_0.b__0 (MinecraftClient.ChatBot bot) [0x00000] in <0401b4e711114db0a8c3f277e178e060>:0 at MinecraftClient.McClient.DispatchBotEvent (System.Action1[T] action, System.Collections.Generic.IEnumerable1[T] botList) [0x00022] in <0401b4e711114db0a8c3f277e178e060>:0

17:29:03 [WARN] OnInternalCommand: Got error from MinecraftClient.ChatBots.ChatLog: System.IO.IOException: Sharing violation on path /root/Minecraft/chatlog-MinecraftName-ServerAdress.txt at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x0019e] in <533173d24dae460899d2b10975534bb0>:0 at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode) [0x00000] in <533173d24dae460899d2b10975534bb0>:0 at (wrapper remoting-invoke-with-check) System.IO.FileStream..ctor(string,System.IO.FileMode) at MinecraftClient.ChatBots.ChatLog.save (System.String tosave) [0x0003d] in <0401b4e711114db0a8c3f277e178e060>:0 at MinecraftClient.ChatBots.ChatLog.OnInternalCommand (System.String commandName, System.String commandParams, System.String result) [0x00016] in <0401b4e711114db0a8c3f277e178e060>:0 at MinecraftClient.McClient.PerformInternalCommand (System.String command, System.String& response_msg, System.Collections.Generic.Dictionary`2[TKey,TValue] localVars) [0x0012a] in <0401b4e711114db0a8c3f277e178e060>:0

ReinforceZwei commented 3 years ago

Are you running some script that would constantly use command? Since internal command and server chat uses different thread and they may cause this issue.

xXjojaXx commented 3 years ago

I cant acces my files right now because my server is down for maintenance but I will look to find if any script could be the trigger of what you mentioned as soon as possible.

ORelio commented 3 years ago

@xXjojaXx Is it solved on your side?

xXjojaXx commented 3 years ago

I will look on it for the next few days and report then if everything worked fine again. :)

xXjojaXx commented 3 years ago

Now the error showed up again. I dont know why. The bot is on the newest version and there aren't multiple applications running in the same chatlog. Pls have a look in what the error might be again.

ReinforceZwei commented 3 years ago

Please provide log output...

xXjojaXx commented 3 years ago

What do you mean with log output? If you mean the stacjtrace, its still the same as shown above

xXjojaXx commented 3 years ago

This error still happens in the latest development build sometimes without multiple bot on one filenor something like that, still something to fix, but I dont get where it is coming from!

ORelio commented 3 years ago

Reopening - see stack trace in https://github.com/ORelio/Minecraft-Console-Client/issues/1607#issue-903040050

OnInternalCommand: Got error from MinecraftClient.ChatBots.ChatLog: System.IO.IOException: Sharing violation on path /root/Minecraft/chatlog-MinecraftName-ServerAdress.txt at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x0019e] in <533173d24dae460899d2b10975534bb0>:0 at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode) [0x00000] in <533173d24dae460899d2b10975534bb0>:0 at (wrapper remoting-invoke-with-check) System.IO.FileStream..ctor(string,System.IO.FileMode) at MinecraftClient.ChatBots.ChatLog.save (System.String tosave) [0x0003d] in <0401b4e711114db0a8c3f277e178e060>:0 at MinecraftClient.ChatBots.ChatLog.OnInternalCommand (System.String commandName, System.String commandParams, System.String result) [0x00016] in <0401b4e711114db0a8c3f277e178e060>:0 at MinecraftClient.McClient.PerformInternalCommand (System.String command, System.String& response_msg, System.Collections.Generic.Dictionary`2[TKey,TValue] localVars) [0x0012a] in <0401b4e711114db0a8c3f277e178e060>:0