LinqToTwitter我听不到推文

问题描述 投票:0回答:1

[我正在尝试使用GitHub上的示例获取推文,但收到错误消息“底层连接已关闭:提交中发生意外错误”。我不明白。首先,我在Twitter上创建了该应用程序,并使用了Twitter生成的密钥并将其添加到该应用程序中。我对2个属性有疑问,我不知道它们将用于什么用途,也不知道它们是否会引起问题:

1-网站URL-我在Wix上创建了一个网站来填充此字段,但我不了解其用途,因为我只想阅读桌面应用程序中的推文。

2-回调URL-最初我什么都没放,然后我在帖子中看到要放http://127.0.0.1/,我用此信息运行了应用程序,但是我又一次不知道它的用途是因为我将从桌面应用程序中获取推文。

这里是使用的代码和收到的错误!


using System;
using System.Linq;
using System.Threading.Tasks;
using LinqToTwitter;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main()
        {        
            MainAsync().Wait();
        }
        static async Task MainAsync()
        {
            var auth = new SingleUserAuthorizer
            {

                CredentialStore = new InMemoryCredentialStore()
                {
                    ConsumerKey = "MyConsumerKey",
                    ConsumerSecret = "MyConsumerSecret",
                    OAuthToken = "MYOAuthToken",
                    OAuthTokenSecret = "MYOAuthTokenSecret"
                }
            };
            var twitterCtx = new TwitterContext(auth);

            var searchResponse = await (from search in twitterCtx.Search
                                        where search.Type == SearchType.Search 
                                        &&  search.Query == "flamengo"
                                        select search).SingleOrDefaultAsync();

            if (searchResponse != null && searchResponse.Statuses != null)
                searchResponse.Statuses.ForEach(tweet =>
                    Console.WriteLine(
                        "User: {0}, Tweet: {1}",
                        tweet.User.ScreenNameResponse,
                        tweet.Text));
        }
    }
}


System.AggregateException was unhandled
  HResult=-2146233088
  Message=Um ou mais erros.
  Source=mscorlib
  StackTrace:
       em System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
       em System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
       em System.Threading.Tasks.Task.Wait()
       em ConsoleApplication3.Program.Main() na C:\Danilo\Docs\Visual Studio 2015\Projects\ConsoleApplication3\ConsoleApplication3\Program.cs:linha 12
       em System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       em System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       em Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       em System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       em System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       em System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       em System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       em System.Threading.ThreadHelper.ThreadStart()
  InnerException: 
       HResult=-2146233088
       Message=Ocorreu um erro ao enviar a solicitação.
       Source=mscorlib
       StackTrace:
            em System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
            em System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
            em LinqToTwitter.Net.GetMessageHandler.<SendAsync>d__4.MoveNext()
         --- Fim do rastreamento de pilha do local anterior onde a exceção foi gerada ---
            em System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
            em System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
            em LinqToTwitter.TwitterExecute.<QueryTwitterAsync>d__48 1.MoveNext()
         --- Fim do rastreamento de pilha do local anterior onde a exceção foi gerada ---
            em System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
            em System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
            em LinqToTwitter.TwitterContext.<ExecuteAsync>d__136 1.MoveNext()
         --- Fim do rastreamento de pilha do local anterior onde a exceção foi gerada ---
            em System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
            em System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
            em LinqToTwitter.TwitterQueryProvider.<ExecuteAsync>d__8 1.MoveNext()
         --- Fim do rastreamento de pilha do local anterior onde a exceção foi gerada ---
            em System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
            em System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
            em LinqToTwitter.TwitterExtensions.<SingleOrDefaultAsync>d__5 1.MoveNext()
         --- Fim do rastreamento de pilha do local anterior onde a exceção foi gerada ---
            em System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
            em System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
            em System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
            em ConsoleApplication3.Program.<MainAsync>d__1.MoveNext() na C:\Danilo\Docs\Visual Studio 2015\Projects\ConsoleApplication3\ConsoleApplication3\Program.cs:linha 29
       InnerException: 
            HResult=-2146233079
            Message=A conexão subjacente estava fechada: Erro inesperado em um envio.
            Source=System
            StackTrace:
                 em System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
                 em System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)
            InnerException: 
                 HResult=-2146232800
                 Message=Não é possível ler os dados da conexão de transporte: Foi forçado o cancelamento de uma conexão existente pelo host remoto.
                 Source=System
                 StackTrace:
                      em System.Net.TlsStream.EndWrite(IAsyncResult asyncResult)
                      em System.Net.PooledStream.EndWrite(IAsyncResult asyncResult)
                      em System.Net.ConnectStream.WriteHeadersCallback(IAsyncResult ar)
                 InnerException: 
                      ErrorCode=10054
                      HResult=-2147467259
                      Message=Foi forçado o cancelamento de uma conexão existente pelo host remoto
                      NativeErrorCode=10054
                      Source=System
                      StackTrace:
                           em System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult)
                           em System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult)
                      InnerException:

twitter linq-to-twitter
1个回答
0
投票

这看起来类似于我们在此解决的问题,该问题需要设置为TLS 1.2,因为它是一个较旧的.NET版本:

Visual Studio 2015 - Debug with HTTP connection problems

© www.soinside.com 2019 - 2024. All rights reserved.