노현종

Vuln DB 추가 도중 연결 끊김 오류 해결

...@@ -9,6 +9,8 @@ namespace VulnCrawler ...@@ -9,6 +9,8 @@ namespace VulnCrawler
9 { 9 {
10 public static class VulnRDS 10 public static class VulnRDS
11 { 11 {
12 + public static AWS.Account Account { get; set; }
13 + public static string DbName { get; set; }
12 public static MySqlConnection Conn { get; set; } 14 public static MySqlConnection Conn { get; set; }
13 public class Vuln 15 public class Vuln
14 { 16 {
...@@ -97,6 +99,8 @@ namespace VulnCrawler ...@@ -97,6 +99,8 @@ namespace VulnCrawler
97 builder = null; 99 builder = null;
98 Conn = new MySqlConnection(strConn); 100 Conn = new MySqlConnection(strConn);
99 Conn.Open(); 101 Conn.Open();
102 + Account = account;
103 + DbName = dbName;
100 } 104 }
101 public static void InsertVulnData(Vuln vuln) 105 public static void InsertVulnData(Vuln vuln)
102 { 106 {
...@@ -132,6 +136,8 @@ namespace VulnCrawler ...@@ -132,6 +136,8 @@ namespace VulnCrawler
132 last_vulnId = 1; 136 last_vulnId = 1;
133 } 137 }
134 138
139 + Retry:
140 +
135 //DB insert 141 //DB insert
136 try 142 try
137 { 143 {
...@@ -147,6 +153,12 @@ namespace VulnCrawler ...@@ -147,6 +153,12 @@ namespace VulnCrawler
147 catch (Exception e) 153 catch (Exception e)
148 { 154 {
149 Console.WriteLine(e.ToString()); 155 Console.WriteLine(e.ToString());
156 + string es = e.ToString();
157 + if (es.Contains("Connection must be valid and open"))
158 + {
159 + Connect(Account, DbName);
160 + goto Retry;
161 + }
150 Console.ReadLine(); 162 Console.ReadLine();
151 } 163 }
152 // } 164 // }
......