1

当我尝试使用 openstacknetsdk 将档案上传到 Rackspace Cloudfiles 时,我得到了一个System.Net.Sockets.SocketException,上传相同的文件CreateObjectFromFile可以完美地工作。

示例代码:

var rackspaceIdentity = new CloudIdentity { APIKey = "xxx", Username = "xxx" };
var rackspaceProvider = new CloudFilesProvider(rackspaceIdentity);

const string bz2File = @"C:\Users\Jan\AppData\Local\Temp\tmp1B64.tmp";

var containerName = DateTime.Now.Ticks.ToString(CultureInfo.InvariantCulture);
rackspaceProvider.CreateContainer(containerName);
rackspaceProvider.EnableCDNOnContainer(containerName, 3600);

Console.WriteLine("Pre CreateObjectFromFile");
rackspaceProvider.CreateObjectFromFile(containerName, bz2File, progressUpdated: x => Console.WriteLine(x.ToString(CultureInfo.InvariantCulture)));
Console.WriteLine("Post CreateObjectFromFile");

var containerName2 = DateTime.Now.Ticks.ToString(CultureInfo.InvariantCulture);
rackspaceProvider.CreateContainer(containerName2);
rackspaceProvider.EnableCDNOnContainer(containerName2, 3600);

Console.WriteLine("Pre ExtractArchiveFromFile");
rackspaceProvider.ExtractArchiveFromFile(bz2File, containerName2, ArchiveFormat.TarBz2, progressUpdated: x => Console.WriteLine(x.ToString(CultureInfo.InvariantCulture)));
Console.WriteLine("Post ExtractArchiveFromFile");

异常详情:

System.IO.IOException was unhandled
  _HResult=-2146232800
  _message=Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host.
  HResult=-2146232800
  IsTransient=false
  Message=Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host.
  Source=System
  StackTrace:
       at System.Net.Sockets.NetworkStream.MultipleWrite(BufferOffsetSize[] buffers)
       at System.Net.Security._SslStream.StartWriting(SplitWritesState splitWrite, SplitWriteAsyncProtocolRequest asyncRequest)
       at System.Net.Security._SslStream.ProcessWrite(BufferOffsetSize[] buffers, SplitWriteAsyncProtocolRequest asyncRequest)
       at System.Net.TlsStream.MultipleWrite(BufferOffsetSize[] buffers)
       at System.Net.PooledStream.MultipleWrite(BufferOffsetSize[] buffers)
       at System.Net.ConnectStream.InternalWrite(Boolean async, Byte[] buffer, Int32 offset, Int32 size, AsyncCallback callback, Object state)
       at System.Net.ConnectStream.Write(Byte[] buffer, Int32 offset, Int32 size)
       at net.openstack.Providers.Rackspace.ExtendedJsonRestServices.<>c__DisplayClass1.<Stream>b__0(HttpWebRequest req)
       at JSIStudios.SimpleRESTServices.Client.RestServiceBase.<>c__DisplayClass7.<ExecuteRequest>b__6()
       at JSIStudios.SimpleRESTServices.Client.RequestRetryLogic.Execute(Func`1 callback, IEnumerable`1 non200SuccessCodes, Int32 retryCount, Nullable`1 retryDelay)
       at JSIStudios.SimpleRESTServices.Client.RestServiceBase.ExecuteRequest(Uri url, HttpMethod method, Func`3 responseBuilderCallback, Dictionary`2 headers, Dictionary`2 queryStringParameters, RequestSettings settings, Func`2 executeCallback)
       at net.openstack.Providers.Rackspace.ExtendedJsonRestServices.Stream(Uri url, HttpMethod method, Func`3 responseBuilderCallback, Stream content, Int32 bufferSize, Int64 maxReadLength, Dictionary`2 headers, Dictionary`2 queryStringParameters, RequestSettings settings, Action`1 progressUpdated)
       at JSIStudios.SimpleRESTServices.Client.RestServiceBase.Stream(Uri url, HttpMethod method, Stream content, Int32 bufferSize, Int64 maxReadLength, Dictionary`2 headers, Dictionary`2 queryStringParameters, RequestSettings settings, Action`1 progressUpdated)
       at net.openstack.Providers.Rackspace.ProviderBase`1.StreamRESTRequest(CloudIdentity identity, Uri absoluteUri, HttpMethod method, Stream stream, Int32 chunkSize, Int64 maxReadLength, Dictionary`2 queryStringParameter, Dictionary`2 headers, Boolean isRetry, RequestSettings requestSettings, Action`1 progressUpdated)
       at net.openstack.Providers.Rackspace.CloudFilesProvider.ExtractArchive(Stream stream, String uploadPath, ArchiveFormat archiveFormat, String contentType, Int32 chunkSize, Dictionary`2 headers, String region, Action`1 progressUpdated, Boolean useInternalUrl, CloudIdentity identity)
       at net.openstack.Providers.Rackspace.CloudFilesProvider.ExtractArchiveFromFile(String filePath, String uploadPath, ArchiveFormat archiveFormat, String contentType, Int32 chunkSize, Dictionary`2 headers, String region, Action`1 progressUpdated, Boolean useInternalUrl, CloudIdentity identity)
       at RackspaceDriver.Program.Main() in c:\Users\Jan\Documents\Visual Studio Projects\RackspaceDriver\RackspaceDriver\Program.cs:line 31
  InnerException: System.Net.Sockets.SocketException
       _HResult=-2147467259
       _message=An existing connection was forcibly closed by the remote host
       HResult=-2147467259
       IsTransient=false
       Message=An existing connection was forcibly closed by the remote host
       Source=System
       ErrorCode=10054
       NativeErrorCode=10054
       StackTrace:
            at System.Net.Sockets.Socket.MultipleSend(BufferOffsetSize[] buffers, SocketFlags socketFlags)
            at System.Net.Sockets.NetworkStream.MultipleWrite(BufferOffsetSize[] buffers)
       InnerException: 

bz2 文件为 +-170MB。

在查看代码时,我没有看到任何显着差异......

  • 牛顿软件.Json 5.0.8
  • openstack.net 1.3.3.0
  • 简单REST服务 1.3.0.1
4

0 回答 0