2012-01-10 4 views
3

로컬 PC에서 클라이언트 측 azure SDK를 사용하여 실제로 ODD 문제가 있습니다.하늘빛 방울 저장소 다운로드 : 서버 인증에 실패했으나 다시 시도 할 수 있습니다.

CloudBlobClient를 사용하여 파일을 업로드하고 삭제하는 것은 매력과 비슷하지만 파일을 다운로드하려고 할 때 인증 예외 (403 Forbidden)가 발생합니다. 그러나 내가 같은 코드를 다시 시도하면 주위에 다음 번에 FINE이 작동합니다.
누구에게 어떤 아이디어가 있습니까 ???

string blobEndpoint = "http://???.blob.core.windows.net"; 
    string accountName = "???"; 
    string accountKey = "???"; 

     while(retry) 
     { 
      FileStream stream = new FileStream("C:\\temp\\mydownload.jpg", FileMode.Append); 

      try 
      { 
       CloudBlobClient blobClient = 
       new CloudBlobClient(new Uri(blobEndpoint), new StorageCredentialsAccountAndKey(accountName, accountKey)); 

       CloudBlob blob = blobClient.GetBlobReference("documents/drive.png"); 

       blob.DownloadToStream(stream); 

       retry = false; 
      } 
      catch (Exception ee) 
      { 
       if (MessageBox.Show(ee.Message.ToString(), "ARGH!", MessageBoxButtons.RetryCancel) != System.Windows.Forms.DialogResult.Retry) 
        retry = false; 
      } 
      finally 
      { 
       stream.Flush(); 
       stream.Close(); 
      } 

     } 

생성되는 예외는 다음과 같습니다 :뿐만 아니라 PHP를위한 윈도우 애저 SDK를 사용할 때이 문제에 걸쳐 실행 한

Microsoft.WindowsAzure.StorageClient.StorageClientException was unhandled 
    Message=Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. 
    Source=Microsoft.WindowsAzure.StorageClient 
    StackTrace: 
     at Microsoft.WindowsAzure.StorageClient.Tasks.Task`1.get_Result() 
     at Microsoft.WindowsAzure.StorageClient.Tasks.Task`1.Execute() 
     at Microsoft.WindowsAzure.StorageClient.RequestWithRetry.RequestWithRetrySyncImpl[TResult](ShouldRetry retryOracle, SynchronousTask`1 syncTask) 
     at Microsoft.WindowsAzure.StorageClient.TaskImplHelper.ExecuteSyncTaskWithRetry[TResult](SynchronousTask`1 syncTask, RetryPolicy policy) 
     at Microsoft.WindowsAzure.StorageClient.CloudBlob.DownloadToStream(Stream target, BlobRequestOptions options) 
     at Microsoft.WindowsAzure.StorageClient.CloudBlob.DownloadToStream(Stream target) 
     at TestAzure.Form1.button1_Click(Object sender, EventArgs e) in c:\users\richard.donaldson\documents\visual studio 2010\Projects\TestAzure\TestAzure\Form1.cs:line 41 
     at System.Windows.Forms.Control.OnClick(EventArgs e) 
     at System.Windows.Forms.Button.OnClick(EventArgs e) 
     at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) 
     at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) 
     at System.Windows.Forms.Control.WndProc(Message& m) 
     at System.Windows.Forms.ButtonBase.WndProc(Message& m) 
     at System.Windows.Forms.Button.WndProc(Message& m) 
     at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) 
     at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) 
     at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) 
     at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) 
     at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) 
     at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) 
     at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) 
     at System.Windows.Forms.Application.Run(Form mainForm) 
     at TestAzure.Program.Main() in c:\users\richard.donaldson\documents\visual studio 2010\Projects\TestAzure\TestAzure\Program.cs:line 18 
     at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) 
     at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) 
     at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() 
     at System.Threading.ThreadHelper.ThreadStart_Context(Object state) 
     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx) 
     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 
     at System.Threading.ThreadHelper.ThreadStart() 
    InnerException: System.Net.WebException 
     Message=The remote server returned an error: (403) Forbidden. 
     Source=System 
     StackTrace: 
      at System.Net.HttpWebRequest.GetResponse() 
      at Microsoft.WindowsAzure.StorageClient.EventHelper.ProcessWebResponseSync(WebRequest req, EventHandler`1 handler, Object sender) 
     InnerException: {"The remote server returned an error: (403) Forbidden."} 
+0

+1 코드 샘플과 함께 올바른 형식의 질문이있는 경우. 또한 "ARGH!"를 사용하여 상상의 포인트를 +1하십시오. 메시지 박스 제목으로. – ean5533

답변

0

여기

문제를 보여줍니다 몇 가지 간단한 코드입니다 . 그 당시 앱에서 이상한 행동을 발견 했습니까? I.E. 느린 응답, 주요 네트워크 대기 시간 등

추가 : 또한 루프처럼 여러 연결을 빠르게 만들었습니까?

+0

아니요 - 단일 연결입니다. – user1141368

+0

하하하. 가. 방금 HTTPS로 변경했으며 이제는 정상적으로 작동합니다. 어쨌든 SSL을 사용해야하므로 걱정할 필요가 없습니다.하지만 http 엔드 포인트와 함께 작동해야합니다. – user1141368

2

하하하. 가. 방금 HTTPS으로 변경했으며 이제는 정상적으로 작동합니다. 어쨌든 SSL을 사용해야합니다. 실제로 걱정할 필요는 없지만 HTTP 엔드 포인트가 아닌 범위에서 작동해야합니다.