2

ツイートとフォローには twitterizer を使用しますが、ファイル TwitterCommand.cs では、オンラインで

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

例外が発生します: 基になる接続が閉じられました: 維持されると予想されていた接続がサーバーによって閉じられました。

exceptionResponse は null であるため、上のコードは例外をスローするように見えます。

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

if (exceptionResponse == null)
{
    throw;
}

なぜそうなのか理解できません=\

コード内の Uri: 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: 
4

1 に答える 1

0

接続の問題のようです。プロキシ/ファイアウォールの設定を確認してください。また、同期呼び出しを試して、動作するかどうかを確認してください。(そうはならないと思いますが、問題のデバッグに役立つかもしれません。)

于 2012-11-26T17:10:58.357 に答える