PsychoTea / Oxide.Ext.Discord

Discord extension and integration
https://umod.org/extensions/discord
12 stars 25 forks source link

NRE halting extension #12

Closed Slut closed 6 years ago

Slut commented 6 years ago

Error below seems to lock up the extension.

10:29 PM [Error] An exception was thrown! (NullReferenceException: Object reference not set to an instance of an object) 10:29 PM [Stacktrace] at Oxide.Ext.Discord.REST.Request.Fire (Oxide.Ext.Discord.REST.Bucket bucket) [0x00000] in :0 at Oxide.Ext.Discord.REST.Bucket.FireRequests () [0x00000] in :0 at Oxide.Ext.Discord.REST.Bucket.RunThread () [0x00000] in :0 at Oxide.Ext.Discord.REST.Bucket.<.ctor>b__27_0 () [0x00000] in :0

Slut commented 6 years ago

Not seeing this error anymore.

Slut commented 6 years ago

Saw the error again today, bot doesn't listen to discord and appears offline but messages are sent to discord from plugin..

Slut commented 6 years ago
1:01 PM [Error] [Discord Ext] Request callback raised an exception (NullReferenceException: Object reference not set to an instance of an object)
  at Oxide.Plugins.PlayerData+<SendDiscordUserMessage>c__AnonStorey12.<>m__0 (Oxide.Ext.Discord.DiscordObjects.Message Message) [0x00000] in <filename unknown>:0 
  at Oxide.Ext.Discord.REST.RESTHandler+<>c__DisplayClass6_0`1[Oxide.Ext.Discord.DiscordObjects.Message].<DoRequest>b__0 (Oxide.Ext.Discord.REST.RestResponse response) [0x00000] in <filename unknown>:0 
  at Oxide.Ext.Discord.REST.Request.Fire (Oxide.Ext.Discord.REST.Bucket bucket) [0x00000] in <filename unknown>:0 
PsychoTea commented 6 years ago

Sounds like the WS is getting closed/halted but the REST api is still running. Very strange behaviour, considering the REST api appears to be where those errors are happening.

Slut commented 6 years ago

I put this in the plugin and it happened again but the function wasn't called...

private void DiscordSocket_WebSocketClosed(string reason, int code, bool clean) => LogToFile(Name, $"{DateTime.Now.ToString()} | SOCKET CLOSED! - {reason} CLEAN: {clean} CODE: {code}", this);
DDraBB commented 6 years ago

@Slut Do you get constant rate limit warnings as well? If not how much population / where is your server located?

Slut commented 6 years ago

I do get warnings but it shouldn't be an issue, are you using the latest development build?

DDraBB commented 6 years ago

@slut Should be the latest build. Unfortunately the extension itself crashes everyday. Wipe days are the worst. One of the plugins that we use gets to the point where it’s 10-20 minuets behind the actual server chat.

Slut commented 6 years ago

Yeah, trying to find the cause of that issue because it seems to be a one-way websocket when it crashes.

Slut commented 6 years ago

1/24/2018 1:49:25 AM | SOCKET CLOSED! - �o��/l�� �� S��e��r�� ��t��i�� CLEAN: True CODE: 1001

Not 100% sure if this is the cause of it as 1001 code means "Going Away" Also not sure how to parse that reason

1001 | Going Away | The endpoint is going away, either because of a server failure or because the browser is navigating away from the page that opened the connection.

DDraBB commented 6 years ago

I'm almost 100% that the new extension is freezing up my server somehow. Seems to be the only thing in the logs causing an error before the server freezes. Send me a pm on Discord and i'll send you the logs.

riddlenl commented 6 years ago

Got the closing socket as well after +/- 3 hours of server-start. Discord bot is offline and not responding :)

Anything I can test as well?

DDraBB commented 6 years ago

Unfortunately we're not sure what causes that. Not sure if you can pull older updates of the extension as there used to be an auto reconnect feature. If you use it you're risking getting banned by Discord by spam reconnects however. As long as you're not using an intense plugin that is used constantly you should be fine though.

Slut commented 6 years ago

It really depends how frequent the disconnects happen, if you find that it doesn't happen often then feel free to use the auto reconnect feature.

riddlenl commented 6 years ago

Ah, thanks. Didn't notice that. Looks like it happens +/- 3 hours after server restart, but I figure there's no way to manually restart the extension to check if it happens more frequently then?

Slut commented 6 years ago

Use this and when it closes again go into the Oxide Logs folder and let me know what message it displays. SocketClosed.zip

riddlenl commented 6 years ago

Will do :)

Slut commented 6 years ago

3/15/2018 10:31:30 PM|Fatal|WebSocket.b170_2|WebSocketSharp.WebSocketException: The header of a frame cannot be read from the stream. at WebSocketSharp.WebSocketFrame.processHeader (System.Byte[] header) [0x00000] in <filena me unknown>:0 , at WebSocketSharp.WebSocketFrame+<>c__DisplayClass73_0.b0 (System.Byte[ ] bytes) [0x00000] in :0 at WebSocketSharp.Ext+<>c__DisplayClass54_0.b__0 (IAsyncResult ar) [0x0000 0] in :0 [Discord Ext] Discord connection closed uncleanly: code 1006, Reason: An exception has occurred while receiving. [Discord Ext] Attempting to reconnect to Discord...�

riddlenl commented 6 years ago

Miraculously I din't see any disconnect issues after two weeks ago...

DDraBB commented 6 years ago

A command to manually disconnect / reconnect the extension would be great. Restarting the server to re-establish the connection kinda sucks.

DDraBB commented 6 years ago

This is the error I have in logs before I was getting closed for code 1000:

5:55 AM [Error] An exception was thrown! (WebException: The operation has timed out.) 5:55 AM [Stacktrace] at System.Net.WebConnectionStream.Read (System.Byte[] buffer, Int32 offset, Int32 size) [0x00000] in :0 at System.IO.StreamReader.ReadBuffer () [0x00000] in :0 at System.IO.StreamReader.Read (System.Char[] buffer, Int32 index, Int32 count) [0x00000] in :0 at System.IO.StreamReader.ReadToEnd () [0x00000] in :0 at Oxide.Ext.Discord.REST.Request.ParseResponse (System.Net.WebResponse response) [0x00000] in :0 at Oxide.Ext.Discord.REST.Request.Fire (Oxide.Ext.Discord.REST.Bucket bucket) [0x00000] in :0 at Oxide.Ext.Discord.REST.Bucket.FireRequests () [0x00000] in :0 at Oxide.Ext.Discord.REST.Bucket.RunThread () [0x00000] in :0 at Oxide.Ext.Discord.REST.Bucket.<.ctor>b__27_0 () [0x00000] in :0

Slut commented 6 years ago

I wonder how that happens, surely @PsychoTea will know