防火墙:入站规则已经存在,是否需要入站?

我开发了一个MVC Web应用程序,它具有Web API并托pipe在Amazon Instance中,一个Windows应用程序用于调用这些API以获取来自该服务器的响应。

Web和Windows应用程序都是使用c#语言在asp.net framework 4.5中开发的。

Windows应用程序安装在more than 200 client's系统中,它们是自我保护的高度安全的服务器,所有入站端口都在防火墙中被阻止。

我正在使用HttpWebRequest和BindIPEndPoint使用configuration的TCP端口范围调用Web API [default 7777-7786]

如果有“允许入站和出站”防火墙规则,API调用可以在Windows应用程序中正常工作。

但问题是,客户端不允许我任何入站防火墙规则,他们只允许这些端口范围的出站防火墙规则和Windows应用程序不处理阻止这些端口范围的入站规则。

是否必须打开防火墙中的入站规则,以便调用/从API获取请求/响应的端口范围? 如果不需要入站防火墙规则,那么请解释为什么?


下面是我的Windows应用程序中使用一个静态TCP端口的API调用

 try { string address = RevWatchURL; address = address + "api/GetRevGuardLatestPatch"; HttpWebRequest httpWebRequest = WebRequest.Create(address) as HttpWebRequest; httpWebRequest.ContentType = "text/json"; httpWebRequest.Method = "POST"; httpWebRequest.Timeout = 300000; httpWebRequest.ServicePoint.BindIPEndPointDelegate = new BindIPEndPoint(CommonValues.BindIPEndPointCallbackRGPatch); string enRevGuardUniqueId = Encryption.EncryptionTechnique(Convert.ToString(UniqueId), null, null); using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())) { string json = "{\"UniqueId\":\"" + enRevGuardUniqueId + "\"}"; streamWriter.Write(json); streamWriter.Flush(); streamWriter.Close(); } try { var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse(); using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) { returnVal = streamReader.ReadToEnd(); streamReader.Close(); httpResponse.Close(); } } catch (WebException ex) { } finally { httpWebRequest.Abort(); } Obj = JsonConvert.DeserializeObject<CommonValues.RevGuardPatchClass>(returnVal); } catch (Exception ex) { MessageBox.Show("Error", "API", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } 

BindIPEndPoint方法:

 public static IPEndPoint BindIPEndPointCallbackRGPatch(ServicePoint servicePoint, IPEndPoint remoteEndPoint, int retryCount) { return new IPEndPoint(IPAddress.Any, 7777); }