浏览代码

处理SocketException

陈国伟 3 年之前
父节点
当前提交
b5647312bf
共有 1 个文件被更改,包括 5 次插入0 次删除
  1. 5 0
      FastGithub.DomainResolve/DnsClient.cs

+ 5 - 0
FastGithub.DomainResolve/DnsClient.cs

@@ -130,6 +130,11 @@ namespace FastGithub.DomainResolve
             {
             {
                 return Array.Empty<IPAddress>();
                 return Array.Empty<IPAddress>();
             }
             }
+            catch (SocketException ex)
+            {
+                this.logger.LogWarning($"{endPoint.Host}@{dns}:{ex.Message}");
+                return this.dnsCache.Set(key, Array.Empty<IPAddress>(), this.maxTimeToLive);
+            }
             catch (Exception ex)
             catch (Exception ex)
             {
             {
                 this.logger.LogWarning($"{endPoint.Host}@{dns}:{ex.Message}");
                 this.logger.LogWarning($"{endPoint.Host}@{dns}:{ex.Message}");