nwesterhausen / valheim-discordconnector

A plugin to connect a Valheim server to a discord webhook.
https://discord-connector.valheim.games.nwest.one/
MIT License
27 stars 13 forks source link

exception thrown on shouts and joins #85

Closed maxfield-allison closed 3 years ago

maxfield-allison commented 3 years ago

After the most recent updates everything was functional, Deleted the 8-10 assemblies from the original mod and replaced with the 4 new ones. after several hours messages stopped coming in on player joins and leaves, shouts fail. exception trace below:

Oct 26 13:44:47 /supervisord: valheim-server 10/26/2021 13:44:47: Exception in ZRpc::HandlePackage: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object

Oct 26 13:44:47 /supervisord: valheim-server   at DiscordConnector.Records.Retrieve (System.String key, System.String playername) [0x00034] in <362c3a87e03241c386f3033225abd7e1>:0 

Oct 26 13:44:47 /supervisord: valheim-server   at DiscordConnector.Patches.ChatPatches+OnNewChatMessage.Prefix (UnityEngine.GameObject& go, System.Int64& senderID, UnityEngine.Vector3& pos, Talker+Type& type, System.String& user, System.String& text) [0x002f6] in <362c3a87e03241c386f3033225abd7e1>:0 

Oct 26 13:44:47 /supervisord: valheim-server   at (wrapper dynamic-method) Chat.DMD<Chat::OnNewChatMessage>(Chat,UnityEngine.GameObject,long,UnityEngine.Vector3,Talker/Type,string,string)

Oct 26 13:44:47 /supervisord: valheim-server   at Chat.RPC_ChatMessage (System.Int64 sender, UnityEngine.Vector3 position, System.Int32 type, System.String name, System.String text) [0x00000] in <61ccd86cd3f34ec18173f65479d19a04>:0 

Oct 26 13:44:47 /supervisord: valheim-server   at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)

Oct 26 13:44:47 /supervisord: valheim-server   at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <eae584ce26bc40229c1b1aa476bfa589>:0 

Oct 26 13:44:47 /supervisord: valheim-server    --- End of inner exception stack trace ---

Oct 26 13:44:47 /supervisord: valheim-server   at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00048] in <eae584ce26bc40229c1b1aa476bfa589>:0 

Oct 26 13:44:47 /supervisord: valheim-server   at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <eae584ce26bc40229c1b1aa476bfa589>:0 

Oct 26 13:44:47 /supervisord: valheim-server   at System.Delegate.DynamicInvokeImpl (System.Object[] args) [0x000e7] in <eae584ce26bc40229c1b1aa476bfa589>:0 

Oct 26 13:44:47 /supervisord: valheim-server   at System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args) [0x00008] in <eae584ce26bc40229c1b1aa476bfa589>:0 

Oct 26 13:44:47 /supervisord: valheim-server   at System.Delegate.DynamicInvoke (System.Object[] args) [0x00000] in <eae584ce26bc40229c1b1aa476bfa589>:0 

Oct 26 13:44:47 /supervisord: valheim-server   at RoutedMethod`4[T,U,V,B].Invoke (System.Int64 rpc, ZPackage pkg) [0x0001d] in <61ccd86cd3f34ec18173f65479d19a04>:0 

Oct 26 13:44:47 /supervisord: valheim-server   at ZRoutedRpc.HandleRoutedRPC (ZRoutedRpc+RoutedRPCData data) [0x00022] in <61ccd86cd3f34ec18173f65479d19a04>:0 

Oct 26 13:44:47 /supervisord: valheim-server   at ZRoutedRpc.RPC_RoutedRPC (ZRpc rpc, ZPackage pkg) [0x00023] in <61ccd86cd3f34ec18173f65479d19a04>:0 

Oct 26 13:44:47 /supervisord: valheim-server   at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)

Oct 26 13:44:47 /supervisord: valheim-server   at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <eae584ce26bc40229c1b1aa476bfa589>:0 

Oct 26 13:44:47 /supervisord: valheim-server    --- End of inner exception stack trace ---
nwesterhausen commented 3 years ago

Can you provide the records.json file? Something went wrong when it's trying to read that

maxfield-allison commented 3 years ago

absolutely, in the meantime I'll reset it. renamed to .txt for github records.txt

nwesterhausen commented 3 years ago

Looks like it ended up not writing the full file at some point -- its invalid JSON and that's causing the error I believe

nwesterhausen commented 3 years ago

I will have to somehow guarantee I write all the JSON or come up with an alternative for storing the records.

maxfield-allison commented 3 years ago

I think it may be related to the records all being stored in a single line. also, perhaps yaml?

nwesterhausen commented 3 years ago

I'm working on switching to LiteDB to store the records using that tool, since rolling my own has been pretty fragile. It's probably 90% integrated right now, just some testing and polish left for it.

I think the reason it failed to write the entire file is because it's set to do it async in another task and could fail/have issue and not really be evident.

nwesterhausen commented 3 years ago

With the LiteDB change (plugin version 1.5.0+), this issue should be resolved.