Why would S3 bucket connection require EC2 access when connecting from a remote app - amazon-s3

I have an .NET app that upload files to S3 bucket. The app hosted in a server in a closed network, so we created firewall rule to whitelist outbound traffic to S3(AP-Southeast-2) IP ranges. We noticed that there are intermittent connection issues and throwing following exception;
Amazon.Runtime.AmazonServiceException: A WebException with status SendFailure was thrown. ---> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
We no longer get intermittent connection issue when we allow all outbound traffic. But we noticed that there are outbound traffic to EC2 IP range as well.
Question: Why would S3 bucket connection require EC2 access when connecting from a remote app?

Related

What is the difference between "Manually Triggered" and "Individual CI" in Azure DevOps Pipeline?

I am running into a problem that, Azure DevOps runs without a problem when I trigger manually, but throws error when it runs automatically.
The error is about SSL certificate verification. I use self signed certificate, but I set up the configuration and gave GIT_SSL_NO_VERIFY = 1 in pipeline variables.
It must work with this configuration and works when run by manual trigger. But it is giving error when it is run by automated process. Error is:
An exception occurred while polling the repository. Error: Microsoft.TeamFoundation.Build2.Server.Extensions.ExternalConnectorException: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. ---> System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.
at System.Net.TlsStream.EndWrite(IAsyncResult asyncResult)
at System.Net.ConnectStream.WriteHeadersCallback(IAsyncResult ar)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)
--- End of inner exception stack trace ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.VisualStudio.Services.Common.VssHttpMessageHandler.<SendAsync>d__17.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.TeamFoundation.Build2.Server.Extensions.GitConnector.GetBranches(IVssRequestContext requestContext, ExternalConnection connection, Int32 timeoutSeconds, Boolean useAnonymousAccess)
--- End of inner exception stack trace ---
at Microsoft.TeamFoundation.Build2.Server.Extensions.GitConnector.GetBranches(IVssRequestContext requestContext, ExternalConnection connection, Int32 timeoutSeconds, Boolean useAnonymousAccess)
at Microsoft.TeamFoundation.Build2.Server.Extensions.GitSourceProvider.GetMatchingBranchRefs(IVssRequestContext requestContext, BuildDefinition definition, IList`1 branchFilters)
at Microsoft.TeamFoundation.Build2.Server.Extensions.GitSourceProvider.GetSourceVersionsToBuild(IVssRequestContext requestContext, BuildDefinition definition, List`1 branchFilters, Boolean batchChanges, String previousVersionEvaluated, Dictionary`2& ciData, String& lastVersionEvaluated)
at Microsoft.TeamFoundation.Build2.Server.Extensions.BuildPollingJobExtension.Run(IVssRequestContext requestContext, TeamFoundationJobDefinition jobDefinition, DateTime queueTime, String& resultMessage).
Is this a bug of Azure DevOps, or am I doing something wrong?

System.Net.Http.HttpRequestException: Cannot assign requested address

I have deployed a .NET Core API on Nginx server on Linux. My API internally calls third party API using HTTPClient.PostAsJsonAsync method.
System is working fine in normal load, but in case of heavy load i am getting below error.
System.Net.Http.HttpRequestException: Cannot assign requested address
---> System.Net.Sockets.SocketException: Cannot assign requested address\n at System.Net.Http.ConnectHelper.ConnectAsync(String host,
Int32 port, CancellationToken cancellationToken)\n --- End of inner
exception stack trace ---\n at
System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port,
CancellationToken cancellationToken)\n at
System.Threading.Tasks.ValueTask1.get_Result()\n at System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)\n at System.Threading.Tasks.ValueTask1.get_Result()\n at
System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask1 creationTask)\n at System.Threading.Tasks.ValueTask1.get_Result()\n
at
System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage
request, Boolean doRequestAuth, CancellationToken cancellationToken)\n
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage
request, CancellationToken cancellationToken)\n at
System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask,
HttpRequestMessage request, CancellationTokenSource cts, Boolean
disposeCts)\n at
MyCard.Middleware.Controllers.DefaultController.CallAndGetESBResponse(Object
requestModel, API apiInfo)
Can any one help me to solve this?

Cannot connect to rabbitmq

Can not connect to internal Rabbit MQ instance. Receive following error:
The AMQP operation was interrupted: AMQP close-reason, initiated by Library, code=541, text="Unexpected Exception", classId=0, methodId=0, cause=System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at RabbitMQ.Client.Impl.Frame.ReadFrom(NetworkBinaryReader reader)
at RabbitMQ.Client.Impl.SocketFrameHandler_0_9.ReadFrame()
at RabbitMQ.Client.Impl.ConnectionBase.MainLoopIteration()
at RabbitMQ.Client.Impl.ConnectionBase.MainLoop()
Could it be that my firewall is blocking required port?
Ok, problem solved. Not sure if would be helpful for someone, but: there was old MassTransit (RabbitMQ client) version, which required to set in URI not just vhost, but also queue address.

An existing connection was forcibly closed by the remote host on WCF

We are getting following issue in our Production environment only. rest of environments its working fine.
we checked various links on stackoverflow but nothing worked.
tried increasing `
<httpRuntime maxRequestLength="2147483647" />
increased timeout
put tracing, but even that not showing any specific issue
[SocketException (0x2746): An existing connection was forcibly closed by the remote host]
System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) +245
[IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.]
System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) +7867549
System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size) +22
System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead) +408
[WebException: The underlying connection was closed: An unexpected error occurred on a receive.]
System.Net.HttpWebRequest.GetResponse() +7870788
System.ServiceModel.Channels.HttpChannelRequest.WaitForReply(TimeSpan timeout) +99
[CommunicationException: An error occurred while receiving the HTTP response to http://myservice/Service.svc. This could be due to
the service endpoint binding not using the HTTP protocol. This could
also be due to an HTTP request context being aborted by the server
(possibly due to the service shutting down). See server logs for more
details.]
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +4728419
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +1725
MyService.ISSO.ProcessRequest(SSORequest request) +0
"Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host."
This error could be generated because of Group Policy Settings. Try connecting to Analysis Service using SQL Management Studio, if error persist try to elevate the user privilages.

WCF Session problem

I'm new to WCF and have not much idea. By using a sample code I tried WCF through remoting...
It works fine for few min but if i leave the client without accessing the WCF server I get an exception like this....
Exception:Unable to connect to the remote server.
Inner Exception :
System.Net.Sockets.SocketException: 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 122.165.27.38:80
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
Stack Trace :
at System.Net.HttpWebRequest.GetRequestStream()
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at TeleMailer.TeleMailer.cbxtmuname_SelectedIndexChanged(Object sender, EventArgs e)
Source :
System
Exception :Server was unable to process request. ---> The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.
Inner Exception :
Stack Trace :
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at TeleMailer.Server.Service.get_path()
at TeleMailer.TeleMailer.TeleMailer_Load(Object sender, EventArgs e)
Source :
System.Web.Services
But it's not in faulted state nor it's closed!!!
Actually in my application the client communicates to the server which in turn contacts the WCF and gives him the work to do....
Right now I'm using Cassini as my server. It works great for few min but after nearly ten min it just shows this error message.... but if i restart my Cassini it works properly for few min again and gets the problem....
I cant understand how it goes to faulted state when it's able to connect more clients....
is it because the session has timed out or what? and if session has timed out then from which side from my server or client???
Any Idea plz..........
I've been siting with it for whole day but could not trace out any thing!!!
It may be a timeout problem, related to when you create the wcf proxy object in your client code.
It looks like you create the proxy object when you start the client and then just reuse it. This object maintains a connection to the server, which timesout after 10 min.
A better way to do it would be to create a new proxy object with a using statement, each time you need it.
" if i leave the client without accessing the WCF server I get an exception like "
May be due to inactivityTimeout, so you can increase it, or dispose your client object as soon as possible (try using statement)
you can set the property as follows
<reliableSession ordered="true" inactivityTimeout="00:00:05"
enabled="false" />