2012-11-26 110 views
2

我用twitterizer的啁啾和以下,但在文件TwitterCommand.cs,上線Twitterizer底層連接被關閉

responseData = ConversionUtility.ReadStream(exceptionResponse.GetResponseStream()); 

我得到一個異常:基礎連接已關閉:這是預期的連接保持活着被服務器關閉。

exceptionResponse爲空,所以代碼上看起來像拋出異常:

// The exception response should always be an HttpWebResponse, but we check for good measure. 
HttpWebResponse exceptionResponse = wex.Response as HttpWebResponse; 

if (exceptionResponse == null) 
{ 
    throw; 
} 

不明白爲什麼會這樣= \

開放的,這是代碼:http://api.twitter.com/1/statuses/update.json,所以,有更新狀態(推特)時的例外情況。

要更新我用這個代碼:

TwitterStatusAsync.Update(token, tweet, null, TimeSpan.FromSeconds(0), (resp) => 
     { 
      TwitterAsyncResponse<TwitterStatus> response = resp; 
      if (response.Result != RequestResult.Success) 
      { 
       this._twtLogger.addLine(String.Format("{0}: error when get response from server", account.title)); 
       this._twtLogger.addLine(String.Format("{0}: {1}", account.title, response.ErrorMessage)); 
       return; 
      } 

      this._twtLogger.addLine(String.Format("{0}> {1}: Tweeted ok!", response.ResponseObject.CreatedDate, account.title)); 
     }); 

補充:

System.Net.WebException was unhandled by user code 
    Message=The underlying connection was closed: A connection that was expected to be kept alive was closed by the server. 
    Source=System 
    StackTrace: 
     at System.Net.HttpWebRequest.GetResponse() 
     at Twitterizer.WebRequestBuilder.ExecuteRequest() 
     at Twitterizer.Core.TwitterCommand`1.ExecuteCommand() 
     at Twitterizer.Core.CommandPerformer.PerformAction[T](ICommand`1 command) 
     at Twitterizer.TwitterFriendship.Create(OAuthTokens tokens, Decimal userId, CreateFriendshipOptions options) 
     at Twitterizer.TwitterFriendship.Create(OAuthTokens tokens, Decimal userId) 
     at Twtt2.Core.TwitterActions.twtActions.Follow(twtTwitterAccount account, QueueElement QueElement, OAuthTokens token) in C:\Users\fs\Documents\Visual Studio 2010\Projects\Twtt2\Twtt2\Core\TwitterActions\twtActions.cs:line 148 
     at Twtt2.Core.TwitterActions.twtActions.Process(EQueue eq) in C:\Users\fs\Documents\Visual Studio 2010\Projects\Twtt2\Twtt2\Core\TwitterActions\twtActions.cs:line 40 
     at Twtt2.Core.AppQueueProcessor.<QueueProc>b__7(EQueue eq) in C:\Users\fs\Documents\Visual Studio 2010\Projects\Twtt2\Twtt2\Core\AppQueueProcessor.cs:line 90 
     at System.Threading.Tasks.Parallel.<>c__DisplayClass2d`2.<ForEachWorker>b__23(Int32 i) 
     at System.Threading.Tasks.Parallel.<>c__DisplayClassf`1.<ForWorker>b__c() 
    InnerException: System.IO.IOException 
     Message=Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. 
     Source=System 
     StackTrace: 
      at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) 
      at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size) 
      at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead) 
     InnerException: System.Net.Sockets.SocketException 
      Message=An existing connection was forcibly closed by the remote host 
      Source=System 
      ErrorCode=10054 
      NativeErrorCode=10054 
      StackTrace: 
       at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) 
       at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) 
      InnerException: 
+0

你能發佈異常的堆棧跟蹤嗎? –

+0

我怎麼能這樣做? – user1612334

+0

補充說,是嗎? – user1612334

回答

0

這似乎是一個連接問題。檢查您的代理/防火牆設置。另外,嘗試同步調用,看看它是否工作。 (我懷疑它不會,但它可能會幫助你調試該問題。)

+0

這種情況發生在30分鐘或1小時後很好的推文。 = \ – user1612334

+0

不能理解如何解決這個問題:(同步崩潰與異常太。 – user1612334

相關問題