Kicking players when communicating through DiscordError

Players are getting kicked fromt he server when we try to type through the rustcord intergration, getting the following message:

Failed to call hook 'Discord_MessageCreate' on plugin 'Rustcord v1.8.2' (ArgumentException: Invalid arguments: InputOffset and OutputOffset must be within the Length of their respective streams.) at EasyAntiCheat.Server.Hydra.NativeNetProtect.ProtectMessage (System.IntPtr ClientObject, System.IO.MemoryStream Input, System.Int64 InputOffset, System.IO.MemoryStream Output, System.Int64 OutputOffset) [0x00013] in <465abc028c31478f8f53797793cf394e>:0
at EasyAntiCheat.Server.Hydra.NetProtect.NetProtect`1[TClient].ProtectMessage (TClient Client, System.IO.MemoryStream Input, System.Int64 InputOffset, System.IO.MemoryStream Output, System.Int64 OutputOffset) [0x00015] in <465abc028c31478f8f53797793cf394e>:0
at EACServer.Encrypt (Network.Connection connection, System.IO.MemoryStream src, System.Int32 srcOffset, System.IO.MemoryStream dst, System.Int32 dstOffset) [0x00010] in :0
at NetworkCryptographyServer.EncryptionHandler (Network.Connection connection, System.IO.MemoryStream src, System.Int32 srcOffset, System.IO.MemoryStream dst, System.Int32 dstOffset) [0x0001a] in :0
at NetworkCryptography.EncryptCopy (Network.Connection connection, System.IO.MemoryStream stream, System.Int32 offset) [0x0002d] in :0
at Facepunch.Network.Raknet.StreamWrite.Send (Network.SendInfo info) [0x00055] in :0
at ConsoleNetwork.BroadcastToAllClients (System.String strCommand, System.Object[] args) [0x0007e] in :0
at Oxide.Plugins.RustPlugin.PrintToChat (System.String format, System.Object[] args) [0x00031] in :0
at Oxide.Plugins.Rustcord.Discord_MessageCreate (Oxide.Ext.Discord.DiscordObjects.Message message) [0x00251] in :0
at Oxide.Plugins.Rustcord.DirectCallHook (System.String name, System.Object& ret, System.Object[] args) [0x01019] in :0
at Oxide.Plugins.CSharpPlugin.InvokeMethod (Oxide.Core.Plugins.HookMethod method, System.Object[] args) [0x00079] in <9affce1cd15c4ec183941adef8db1722>:0
at Oxide.Core.Plugins.CSPlugin.OnCallHook (System.String name, System.Object[] args) [0x000d8] in <4452f821def6406d834e4149849fe7ea>:0
at Oxide.Core.Plugins.Plugin.CallHook (System.String hook, System.Object[] args) [0x00060] in <4452f821def6406d834e4149849fe7ea>:0

Has anyone else experienced this???

Players are still being kicked when talking through the Rustcord discord intergration, I have spoken to them and they are saying its an extension issue, is anyne else still getting this issue??
BigEasy001
Players are still being kicked when talking through the Rustcord discord intergration, I have spoken to them and they are saying its an extension issue, is anyne else still getting this issue??
Discord extension is kinda buggy atm, I think you should open issue in the extension help thread or in the rustcord thread
5ba0b9633e817.png?uid=5ba0b9716c220 2CHEVSKII
Discord extension is kinda buggy atm, I think you should open issue in the extension help thread or in the rustcord thread
It was moved here as it didn't look to be related to them.
Well I have tried to bring the issue up in both the rustcord and discord extension threads and have recieved no feedback on when this will be fixed, appreciate the work that goes into it, just trying to get a rough timeframe on a fix is all :)

Do all messages cause this error or only specific messages?

In either case, discord messages may be violating some inherent contraint within the Rust client like encoding, encryption, special characters, or length.

If only specific messages, what are some examples of those messages?  Is there any commonality between the messages that might cause this error?

I have submitted a very simple patch to Rustcord which will print messages to the server console _before_ this exception is thrown by PrintToChat.  The current Rustcord (1.8.2) only prints messages to console after PrintToChat, and as such nothing will be printed to console in the case this exception is thrown.  By reversing the order of these operations, we should have a better idea of what the message that is that is causing this error.



Merged post

@OuTSMoKE

Its hard to say, I'll try run a stress test on it now, see what causes it to kick people. It's just so strange that it kicks a certain amount of people out, and not everyone, or crash the server, it just boots a random number. I'll let you know what I find!

Thanks for the detailed reply, very helpful!!!

After touching base with the developers of Rustcord, the issue doesn't appear to be related to the message contents as I originally suspected, but rather due to the fact that the discord hook is invoked from a separate thread and as such will occassionally result in a race condition that causes unexpected behavior, such as this NRE.

@Tricky any chance you could change all hooks invoked by the discord extension to be invoked within a NextFrame delegate/anonymous function to prevent this race condition?
Not receiving post notifications for some reason
 Yes, I'll do it now thanks!
Thanks for the hard work guys!! Cheers for looking into this, been driving me crazy ?
5d40a5812fe5a.png Calytic
After touching base with the developers of Rustcord, the issue doesn't appear to be related to the message contents as I originally suspected, but rather due to the fact that the discord hook is invoked from a separate thread and as such will occassionally result in a race condition that causes unexpected behavior, such as this NRE.

@Tricky any chance you could change all hooks invoked by the discord extension to be invoked within a NextFrame delegate/anonymous function to prevent this race condition?

11:30 [Warning] [Discord Ext] An error has occured: Response: An error has occurred in sending data.
11:30 [Warning] [Discord Ext] An error has occured: Response: An error has occurred in sending data.

Uhm yeah, this caused a crash/lagout earlier (i'm pretty sure), this was the last set of messages logged when I went and checked. I'm assuming this is the cause of the crash but not 100%, it wasn't really a crash, I had to reboot the server myself, rather than RSM rebooting it cause it never even shut down in the first place. Was basically just on lockdown.0
Here is the error I'm getting for everyone on the server randomly when trying to send a message through rustcord (discord to server). Note, this doesn't happen every time.
STEAMID & NAME disconnecting: NotImplementedException: Unknown wire type: 6
SilentOrbit.ProtocolBuffers.ProtocolParser.SkipKey (System.IO.Stream stream, SilentOrbit.ProtocolBuffers.Key key) (at <00000000000000000000000000000000>:0)
ProtoBuf.Entity.Deserialize (System.IO.Stream stream, ProtoBuf.Entity instance, System.Boolean isDelta) (at <00000000000000000000000000000000>:0)
ProtoBuf.Entity.Deserialize (System.IO.Stream stream) (at <00000000000000000000000000000000>:0)
Client.OnEntities (Network.Message packet) (at <00000000000000000000000000000000>:0)
Client.OnNetworkMessage (Network.Message packet) (at <00000000000000000000000000000000>:0)
Facepunch.Network.Raknet.Client.HandleMessage () (at <00000000000000000000000000000000>:0)
Facepunch.Network.Raknet.Client.Cycle () (at <00000000000000000000000000000000>:0)
Client.Update () (at <00000000000000000000000000000000>:0)
UnityEngine.Debug:LogException(Exception)
Facepunch.Network.Raknet.Client:HandleMessage()
Facepunch.Network.Raknet.Client:Cycle()
Client:Update()​

 
Version: 40765
Yepp this is exactly whats been happening to me, its happening to me when talking through rustcord discord intergration, and booted a bunch of players
if you're using rustcord update to the latest version
that should have it fixed