This kind of question has been asked several times, and I understand why it happens, and probably nothing we can do about it except retry.
I do have one question on name resolution though.
I am using AWS .Net SDK for 3.5 .Net. I am uploading a big file (>500MB up to 1.5GB, medical images). I call TransferUtility.Upload() method.
For most part the program works great.
Occasionally we get this error in the middle of the upload. Usually happens when the internet is slow.
I can catch the exception and retry, which means rery from the beginning since exception happens inside the AWS code.
My question is, if the program has resolved the s3 bucket name and has been uploading for a while why would it give me name resolution error instead of just using the cached resolved name?
Does each thread resolve the name independently and one of thread is failing since the network is saturated? Is this a computer setting? This error we were able to reproduce pretty consistently on a Windows 10 machine with Charter as ISP uploading a 800MB file.
The error occurred after about 250MB upload was done.
This is the actual exception
Exception during upload :Amazon.Runtime.AmazonServiceException:
A WebException with status NameResolutionFailure was thrown. --->
System.Net.WebException: The remote name could not be resolved: 'my-bucket.s3.amazonaws.com'
This web exception is telling you the there was an issue with the "Name Resolution". What it doesn't tell you is that the "name" it's referring to is the "EndpointRegion", for example: USEast1, USEast2 etc.
When using the Amazon.S3.Transfer.Transferutility it's crucial that the EndpointRegion you use in the Upload call MATCHES that of the bucket you're uploading into.
In my case using RegionEndpoint.GetBySystemName("USEast1") vs RegionEndpoint.GetBySystemName("US-East-1") was the difference maker.
Another cause for this issue could be DNS resolution. If your system is not able to perform DNS resolves it will give you this same error.
Related
I am working on a .NET API that runs inside of a docker container. At some point it makes a call to a Python Flask API that is also running in a container.
var response = await httpClient.GetAsync("http://service-name:8000/actual/url")
which then produces the following error:
System.Net.Http.HttpRequestException: Resource temporarily unavailable
---> System.Net.Sockets.SocketException (11): Resource temporarily unavailable
at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken
cancellationToken)
Has anyone had experience with this before and potentially knows a solution? I cant find much on the web about it at all. I have some seen some mentions of the issue potentially being related to the Flask API not using async methods but that doesnt make sense to me.
The Flask API produces the appropriate responses when accessed through a web browser or Postman using localhost:8000/actual/url and the container logs these responses. I have tried using the localhost URL in the .NET API but that does not work either.
If anymore information is needed please leave a comment and I will do my best to update the post quickly.
-- Christie
TLDR
A reason for the "Resource temporarily unavailable" error is when during name resolution the DNS Server responds with RCODE 2 (Server failure).
Long answer
I noticed the same behavior in a dotnet application running in a dotnet runtime alpine docker container. Here are the results of my investigation:
The error message "Resource temporarily unavailable" corresponds to the EAGAIN error code which gets returned by various functions from the C standard library. At first I suspected the connect() function because the C# stack trace indicates the error happening during the ConnectAsync() call of the c# socket. And indeed the EAGAIN error code appears in the man page of connect() with this description: "No more free local ports or insufficient entries in the routing cache".
I simulated a system with depleted local ports and noticed that a different exception gets thrown in that case, which rules out local port availability as a root cause for the original exception. Regarding the other mentioned cause in the man page it turns out that the routing cache was removed from Linux in 2012. commit
I started to look around for EAGAIN in the source of the musl C lib which is used in the dotnet runtime alpine docker container. After a while I finally noticed the gethostbyname2_r function which is used for resolving a domain name to an ip address via DNS. During System.Net.Sockets.Socket.ConnectAsync() the hostname is still a string and the name resolving happens in native code using the gethostbyname2_r function (or one of its variations).
The final question is: When does gethostbyname2_r return the EAGAIN error code? It's when the RCODE field in the header of the DNS Response has the value 2, which stands for "Server failure". source line 166
To verify this result I ran a simple mock DNS server which always returns the RCODE 2 in the DNS response. The resulting c# exception along with the stack trace matched the original exception exactly.
I have tiny exe's, I am developing with c# the size is max 100kb - 500kb.
A 3rd party application opens these exes for me, when my application is opened, it reads some data from MySql database, processes it, then writes the result back to MySql database.
they are very normally useful on servers, but sometimes I get this error, it's not clear when, sometimes after 1 week, sometimes twice a day
Authentication to host '192.168.1.200' for user 'root' using method
'mysql_native_password' failed with message: Reading from the stream
has failed.
this error does not happen on every computer, it does not happen all the time, I never encounter it when compiling on my own computer
I tried a lot of things so far I couldn't come to a conclusion by looking at some suggestions on this site
I added or removed MySql password is not a solution , ports defined to firewall and antiviruses
private string connectionstring = "Server={0};Database={1};port={2};username={3};password={4};CharSet=latin1;SslMode=None";
I'm using the NCryptoki dll to manage the acccess to our HSMs.
I use a C# windows service. This service is a socket: it listens for requests and it access to the HSMs, doing stuff.
Using my code to acccess HSM, I randomly get this message:
Cryptware.NCryptoki.CryptokiException: Error n. 145
Only few calls on the total get this message, but it is quite annoying. Do you know why this is happening?
I found 145 is 0x00000091 CKR_OPERATION_NOT_INITIALIZED: There is no active operation of an appropriate type in the specified session
I get this error, for example, when I call the find method:
Cryptware.NCryptoki.CryptokiException: Error n. 145 at Cryptware.NCryptoki.CryptokiObjects.Find(CryptokiCollection attList, Int32 nMaxCount)
It seems like the session isn't valid.
Our service is a listening socket. It gets a big load of requests and, few of them, fail with this message. Do you know why?
The weird point is the same request rarely fails and all the other times works.
You are most likely not using PKCS#11 library and PKCS#11 sessions in multi-threaded environment correctly. See my older answer to similar question for more details.
Okay I tried to play a little bit with the StatsManager but I always got an exception trying to use anything with it when comes to
Set a stat
Get a stat
Because I doubted myself I had the idea just to use the UWPIntegration sample that is on Github . I also added the Leaderboard items to my own project so the code works with my test sandbox. Logging in works as it should just StatsManager causes the issues.
But as with my own code I just get the same error / exception which is the following. I assume there is a bug in the code provided or the service configuration is not working as intended.
System.AggregateException occurred HResult=0x80131500 Message=One or more errors occurred. Source= StackTrace: at
System.Threading.Tasks.Task1.GetResultCore(Boolean
waitCompletionNotification) at
Microsoft.Xbox.Services.XboxLiveHttpRequest.<>c__DisplayClass35_0.<GetResponseWithAuth>b__1(Task1
getResponseTask) in
D:\Data\VisualStudio\Projects\xbox-live-api-csharp\Source\api\XboxLiveHttpRequest.cs:line
117 at System.Threading.Tasks.Task.Execute()
Inner Exception 1: AggregateException: One or more errors occurred.
Inner Exception 2: WebException: The remote server returned an error:
(404) Not Found.
Issue was found. My service.config used a wrong parameter name, see below in the comments of the solution.
There are a few different reasons why this might be the case. Not surprisingly, it means the cloud can't find the stat you've requested.
If you use Fiddler, you can capture the call and share with me the correlationID header. If you don't know Fiddler, let me know and I can help you.
However, some ideas off the top of my head
Make sure that you're in development mode - your sandbox is the one from the dev center site. If you aren't sure, you can use the Windows Device Portal to see what your sandbox is - just click on Xbox Live in the left hand navigation.
Make sure you have hit "Test" on the dev center page where you defined your featured stats and leaderboards.
Make sure you are requesting the stat by the ID name you specified in the config window, not the display name.
I am using the WebClient.UploadFile() method to post files to a service for processing. The file contains an XML document with a compressed, b64-encoded content element in it. For some files (currently 1), the UploadFile throws an exception, indicating that the underlying connection was closed. The innermost exception on socket level gives the message 'An existing connection was forcibly closed by the remote host'.
Questions:
Has anyone necountered the same problem?
Why does it throw an exception for some files, and not for all?
Should I set some additional parameter for files with binary content?
Is there a workaround?
This functionality does work fine in a VPN situation, but obviously we want to use it to work in standard Internet situations.
Thanks, Rine
Sounds like a firewall or other security software sitting in between you and the server may be rejecting the request as a potential attack. I've run into this before where firewalls were rejecting requests that contained a specific file extension-- even if that file extension was encoded in a query string parameter!
If I were you, I'd take the problematic file and start trimming XML out of it. You may be able to find a specific chunk of XML which triggers the issue. Once you've identified the culprit, you can figure out how to get around the issue (e.g. by encoding those characters using their Unicode values instead of as text before sending the files). If, however, any change to the file causes the problem to go away (it's not caused by a specific piece of worrisome text), then I'm stumped.
Any chance it's a size issue and the problematic file is above a certain size and all the working files are below it? The server closing the connection when it hits a max accepted request size matches your symptom. You mentioned it worked in VPN so it's admittedly a stretch, but maybe the VPN case was a different server that's configured differently (or the max request is different for some other reason).
Are there non-WebClient methods for uploading the file to the same service from the same machine and if so, do they work?