none
Receiving error: Microsoft.WindowsAzure.Storage.StorageException: The underlying connection was closed: An unexpected error occurred on a send.--->System.Net.WebException

    Question

  • I'm receiving the following error when trying to upload text to an Azure blob that is created during the same routine.  I've successfully run this code (with the same and different input data) from one Windows 7 machine; however, it fails with the following message from a different Windows 7 machine on a different network.  I'm wondering if it could be a firewall issue, and if getting reserved IP addresses might be solution.

    Here's the error message:

    Microsoft.WindowsAzure.Storage.StorageException: The underlying connection was closed: An unexpected error occurred on a send.--->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 focibily closed by the remote host
    at System.Net.Sockets.Socket.Receive(Byte[],Ine32,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,Ine32 offset,Int32 count)
    at System.Net.Security.SslState.StartReceivedBlob(Bytr[],buffer,AsyncProtocolRequest asyncRequest)
    at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
    at System.Net.Security.SslState.StartSendBlob(Byte[] incoming,Int32 count, AsyncProtocolRequest asyncRquest)
    at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
    at System.Net.Security.SslState.ProcessAuthentication(LaxyAsyncResult lazyResult)
    at System.Net.TlsStrea.CallProcessAuthentication(Object state)
    at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preservceSyncCtx)
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx.)
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
    at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result)
    at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size)
    at system.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Ine32 size)
    at System.Net.ConnectStream.WriteHeaders(Boolean async)
    ---End of inner exception stack trace---
    at System.Net.HttpWebRequest.GetResponse()
    at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand1 cmd, lREtryPolicy policy, OperationContext operationContext)
    ---End of inner exception stack trace---
    at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand1 cmd, lREtryPolicy policy, OperationContext operationContext)
    at Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer.Exists(Boolean primaryOnly, BlobRequestOptions requestOptions, OperationContext operationContext)
    at Microsoft.WindowsAzure.Storage.Blob.CloudBlobContianer.CreateIfNotExists(BlobContainerPublicAccessType accessType, blobRequestOptions requestOptions, OperationContext operationContext)
    at Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer.CreateIfNotExists(BlobRequestOptions requestOptions, OperationContext operationContext)
    at DFNDClient.frmMain.UploadeExtractsAndIniToCloud_StorageConnection(DataSet pDs, String pstrStorageConnectionString, String pstrClientId, String pstrCompanyName, String pstrDateTimeStamp, String& pstrMessaage)
    RequestInformation
    RequestId:
    RequestDate:
    StatusMessage:


    And this is the VB.Net routine which was invoked:

        Private Sub UploadExtractsAndIniToCloud_StorageConnection(ByVal pDs As DataSet, _
                                         ByVal pstrStorageConnectionString As String, _
                                         ByVal pstrClientId As String, _
                                         ByVal pstrCompanyName As String, _
                                         ByVal pstrDateTimeStamp As String, _
                                         ByRef pstrMessage As String)
            Dim dt As DataTable
            Dim oOperationContext As New OperationContext
            Dim strXml As String
            Dim strXml2 As String
            Dim strBlobName As String

            Try
                pstrMessage = "OK"

                Dim oCloudStorageAccount As CloudStorageAccount = CloudStorageAccount.Parse(pstrStorageConnectionString)
                Dim oCloudBlobClient As CloudBlobClient = oCloudStorageAccount.CreateCloudBlobClient()
                Dim oCloudBlobContainer As CloudBlobContainer = oCloudBlobClient.GetContainerReference("xxxxx")
                oCloudBlobContainer.CreateIfNotExists(Nothing, oOperationContext)

                'save extracts to Azure
                For Each dt In pDs.Tables
                    Dim writer As New StringWriter
                    dt.WriteXml(writer, XmlWriteMode.WriteSchema)
                    strXml = writer.ToString
                    strXml = clsEncryptDecrypt.AesEncryptString(strXml)
                    strBlobName = pstrClientId.Trim & "/" & pstrDateTimeStamp & "/" & pstrClientId.Trim & "_" & pstrCompanyName & "_" & dt.TableName & "_" & pstrDateTimeStamp & ".txt"
                    Dim oCloudBlockBlob As CloudBlockBlob = oCloudBlobContainer.GetBlockBlobReference(strBlobName)
                    oCloudBlockBlob.UploadText(strXml)
                Next

                'save file to Azure
                Dim writer2 As New StringWriter
                mdsIni.Tables(0).WriteXml(writer2)
                strXml2 = writer2.ToString
                strXml2 = clsEncryptDecrypt.AesEncryptString(strXml2)
                strBlobName = pstrClientId.Trim & "/" & pstrDateTimeStamp & "/" & pstrClientId.Trim & "_xxxxx_" & pstrDateTimeStamp & ".txt"
                Dim oCloudBlockBlob2 As CloudBlockBlob = oCloudBlobContainer.GetBlockBlobReference(strBlobName)
                oCloudBlockBlob2.UploadText(strXml2)

                'save file to app startup folder
                File.WriteAllText(System.Windows.Forms.Application.StartupPath & "\xxxxx.xml", strXml2)

            Catch ex As Exception
                pstrMessage = ex.ToString
            End Try

        End Sub

    Thanks.

    Friday, January 29, 2016 7:39 PM

All replies