Krunal Mevada

Krunal Mevada

  • NA
  • 13
  • 1k

Firewall : is inbound required for getting response while ou

Oct 14 2016 6:55 AM
I developed one MVC web application which have Web APIs and hosted in Amazon Instance and one windows application for calling those APIs for getting response from that server.
 
Both Web and Windows applications are developed in asp.net framework 4.5 using c# language.
 
Windows application is installed in more than 200 client's system which are highly secure servers it selves with all Inbound ports blocked in Firewall.
 
I am using HttpWebRequest with BindIPEndPoint for calling Web APIs using configured TCP port range [default 7777-7786].
API calls working fine from Windows Application if there are Allow Inbound and Outbound firewall Rules.
 
But the problem is clients are not allowing me any Inbound Firewall rules, they only allowing Outbound Firewall rules for those port range And Windows application is not working with blocked inbound rules for those port range.
 
Is it must I need to open Inbound Rule in Firewall for those port range for calling/getting request/response to/from APIs ? If no need of Inbound Firewall rule then please explain Why ?
 
Below is the API call which use one static TCP port in my Windows Application :
 
  1. try  
  2. {  
  3. string address = RevWatchURL;  
  4. address = address + "api/GetRevGuardLatestPatch";  
  5. HttpWebRequest httpWebRequest = WebRequest.Create(address) as HttpWebRequest;  
  6. httpWebRequest.ContentType = "text/json";  
  7. httpWebRequest.Method = "POST";  
  8. httpWebRequest.Timeout = 300000;  
  9. httpWebRequest.ServicePoint.BindIPEndPointDelegate =  
  10. new BindIPEndPoint(CommonValues.BindIPEndPointCallbackRGPatch);  
  11. string enRevGuardUniqueId =  
  12. Encryption.EncryptionTechnique(Convert.ToString(UniqueId), nullnull);  
  13. using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))  
  14. {  
  15. string json = "{\"UniqueId\":\"" + enRevGuardUniqueId + "\"}";  
  16. streamWriter.Write(json);  
  17. streamWriter.Flush();  
  18. streamWriter.Close();  
  19. }  
  20. try  
  21. {  
  22. var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();  
  23. using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))  
  24. {  
  25. returnVal = streamReader.ReadToEnd();  
  26. streamReader.Close();  
  27. httpResponse.Close();  
  28. }  
  29. }  
  30. catch (WebException ex)  
  31. {  
  32. }  
  33. finally  
  34. {  
  35. httpWebRequest.Abort();  
  36. }  
  37. Obj = JsonConvert.DeserializeObject<CommonValues.RevGuardPatchClass>(returnVal);  
  38. }  
  39. catch (Exception ex)  
  40. {  
  41. MessageBox.Show("Error""API", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);  
  42. }  
 
BindIPEndPoint Method:
 
  1. public static IPEndPoint BindIPEndPointCallbackRGPatch(ServicePoint servicePoint,  
  2. IPEndPoint remoteEndPoint, int retryCount)  
  3. {  
  4. return new IPEndPoint(IPAddress.Any, 7777);  
  5. }  

Answers (1)