[smuxi/stable: 15/15] Engine-Twitter: handle IOException inner-exceptions




commit e079e7b9793a363b1d6715a74b955fc44e8b6cb5
Author: Mirco Bauer <meebey meebey net>
Date:   Wed Jan 27 00:15:26 2021 +0800

    Engine-Twitter: handle IOException inner-exceptions
    
    Twitter has every day IOExceptions thus they need to be treated like temporary
    issues and not permanent issue.
    
    Example:
    
        2021-01-20 05:08:54,628 [TwitterProtocolManager friends timeline listener] ERROR 
Smuxi.Engine.TwitterProtocolManager - UpdateFriendsTimelineThread(): Exception
    
        System.Net.WebException: Unable to read data from the transport connection: Connection reset by peer. 
---> System.IO.IOException: Unable to read data from the transport connection: Connection reset by peer. ---> 
System.Net.Sockets.SocketException: Connection reset by peer
    
          at Smuxi.Engine.TwitterProtocolManager.CheckWebException (System.Net.WebException exception) 
[0x0008d] in <b07886f794b444e6a88ef1ae4c9ed942>:0

 .../Protocols/Twitter/TwitterProtocolManager.cs          | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
---
diff --git a/src/Engine-Twitter/Protocols/Twitter/TwitterProtocolManager.cs 
b/src/Engine-Twitter/Protocols/Twitter/TwitterProtocolManager.cs
index 53574183..03af2bd2 100644
--- a/src/Engine-Twitter/Protocols/Twitter/TwitterProtocolManager.cs
+++ b/src/Engine-Twitter/Protocols/Twitter/TwitterProtocolManager.cs
@@ -1900,6 +1900,22 @@ namespace Smuxi.Engine
                     return;
             }
 
+            if (exception.InnerException != null) {
+                if (exception.InnerException is System.IO.IOException) {
+                    // sometimes data can't be read from the transport connection, e.g.:
+                    // System.Net.WebException: Unable to read data from the transport connection: 
Connection reset by peer
+#if LOG4NET
+                    f_Logger.Warn("CheckWebException(): ignored inner-exception", exception.InnerException);
+#endif
+                    return;
+                } else {
+#if LOG4NET
+                    f_Logger.Error("CheckWebException(): inner-exception", exception.InnerException);
+#endif
+
+                }
+            }
+
             /*
             http://apiwiki.twitter.com/HTTP-Response-Codes-and-Errors
             * 200 OK: Success!


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]