1

I have recently started using the Gmail API as opposed to IMAP. I am using the .Net client library for calling the API.

On a random basis I am recieving the Error

"An error occurred while sending the request" when executing a Get Request of a Message

                    UsersResource.MessagesResource.GetRequest gr = gs.Users.Messages.Get(emailAccount, msgId);
                    if (isRaw)
                    {
                        gr.Format = UsersResource.MessagesResource.GetRequest.FormatEnum.Raw;
                        Message m = gr.Execute();

My observations are that this is a random error that occurs now and then. I can run 10 Requests and then there will be a fail. I am running the same request on the same infrastructure each time.

I have also noted that the performance is not very consistent - it can sometimes take 10 seconds and other times sub-second.

Is anybody else experiencing issues such as this?

Thanks for your help,

UPDATE

I am calling the same message and it is a small one with no attachments. I have a load tester that requests it 100 times. The errors are to do with the closing of an underlying connection. I am going to try a different web host to see if that is a factor. Here are the full error messages:

Error on Message Get

|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.EndReceive(IAsyncResult asyncResult) at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult) --- End of inner exception stack trace --- at System.Net.TlsStream.EndWrite(IAsyncResult asyncResult) at System.Net.PooledStream.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)

Error during authentication

|System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> 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.EndReceive(IAsyncResult asyncResult) at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult) --- End of inner exception stack trace --- at System.Net.TlsStream.EndWrite(IAsyncResult asyncResult) at System.Net.PooledStream.EndWrite(IAsyncResult asyncResult) at System.Net.ConnectStream.WriteHeadersCallback(IAsyncResult ar) --- End of inner exception stack trace --- at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context) at System.Net.Http.HttpClientHandler.GetRequestStreamCallback(IAsyncResult ar) --- End of inner exception stack trace --- at Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task task) at Google.Apis.Auth.OAuth2.ServiceAccountCredential.d__b.MoveNext()

Paul C

4

1 回答 1

1

这是 Azure 托管的问题。

我已经确认,如果我使用 Azure 网站甚至虚拟机,调用 Google API 的错误率是 5-10%。

无论是身份验证、调用 Gmail API 还是日历 API,都会出现同样的问题。

MSFT 没有回应,所以我将在其他地方主持。

希望这可以挽救有同样问题的人。

于 2014-07-13T23:48:28.140 回答