title: A connection attempt failed because the connected party did not properly respond after a period of time - having issue only in aws server
body: <p>I am trying to access a url that ends with .json file from a different server. I have used the below code which is working fine in my development env but when I hosted the in aws server I am getting error.
  Sample URL :  <a href="https://sample.com/sampledata.json" rel="nofollow noreferrer">https://sample.com/sampledata.json</a></p>
  <pre><code>    public dynamic GetHttpData(string urlString)
      {
          string jsonResponse = null;
  
          try
          {
              Uri getUri = new Uri(urlString);
              HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(getUri);
              request.Headers.Add(HttpRequestHeader.Cookie, null);
              request.Accept = &quot;*/*&quot;;                
  
              using (WebResponse response = request.GetResponse())
              {
                  using (StreamReader streamReader = new StreamReader(response.GetResponseStream()))
                  {
                      jsonResponse = streamReader.ReadToEnd();
                  }
              }
          }
          catch (Exception ex)
          {
             
          }
         
          return jsonResponse;
      }
  </code></pre>
  <p>The above code works fine in dev but getting the below error in server.</p>
  <pre><code>An error occurred while sending the request. Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond..
  System.Net.WebExceptionSystem.Net.Http.HttpRequestException: An error occurred while sending the request.
   ---&gt; System.IO.IOException: Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond..
   ---&gt; System.Net.Sockets.SocketException (10060): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
     --- End of inner exception stack trace ---
     at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
     at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.GetResult(Int16 token)
     at System.Net.Security.SslStream.&lt;FillBufferAsync&gt;g__InternalFillBufferAsync|215_0[TReadAdapter](TReadAdapter adap, ValueTask`1 task, Int32 min, Int32 initial)
     at System.Net.Security.SslStream.ReadAsyncInternal[TReadAdapter](TReadAdapter adapter, Memory`1 buffer)
     at System.Net.Http.HttpConnection.FillAsync()
     at System.Net.Http.HttpConnection.ReadNextResponseHeaderLineAsync(Boolean foldedHeadersAllowed)
     at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken)
     --- End of inner exception stack trace ---
     at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken)
     at System.Net.Http.AuthenticationHelper.SendWithNtAuthAsync(HttpRequestMessage request, Uri authUri, ICredentials credentials, Boolean isProxyAuth, HttpConnection connection, HttpConnectionPool connectionPool, CancellationToken cancellationToken)
     at System.Net.Http.HttpConnectionPool.SendWithNtConnectionAuthAsync(HttpConnection connection, HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
     at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
     at System.Net.Http.AuthenticationHelper.SendWithAuthAsync(HttpRequestMessage request, Uri authUri, ICredentials credentials, Boolean preAuthenticate, Boolean isProxyAuth, Boolean doRequestAuth, HttpConnectionPool pool, CancellationToken cancellationToken)
     at System.Net.Http.DiagnosticsHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
     at System.Net.Http.HttpClient.FinishSendAsyncUnbuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
     at System.Net.HttpWebRequest.SendRequest()
     at System.Net.HttpWebRequest.GetResponse() System.Net.Requests
  </code></pre>