I wrote a small WPF application that just displays messages sent to my grpc 
server but sometimes when I connect i get this error

System.AggregateException
  HResult=0x80131500
  Message=One or more errors occurred.
  Source=mscorlib
  StackTrace:
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean 
includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, 
CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.Wait()
   at WpfApp1.MainWindow.Connect() in MainWindow.xaml.cs:line 64
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext 
executionContext, ContextCallback callback, Object state, Boolean 
preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext 
executionContext, ContextCallback callback, Object state, Boolean 
preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext 
executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()
Inner Exception 1:
RpcException: Status(StatusCode=Unknown, Detail="Exception was thrown by 
handler.")
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at 
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
 
task)
   at Grpc.Core.Internal.ClientResponseStream`2.<MoveNext>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task 
task)
   at 
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
 
task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at WpfApp1.LogClient.<ConnectAndListenForMessage>d__3.MoveNext()


If I stop running the program in visual studio and start it again it seems 
to go away but will then come back again once I stop it and try to restart 
it another time. I am not sure what the issue is here but I can 
consistently get it to happen.

This is all my wpf app does

namespace WpfApp1
{


    public class LogClient
    {
        readonly Logger.Logger.LoggerClient client;
        RichTextBox rtb;


        public LogClient(Logger.Logger.LoggerClient client, RichTextBox rtb)
        {
            this.client = client;
            this.rtb = rtb;
        }


        public async Task ConnectAndListenForMessage(Logger.LogMessage 
message)
        {
            var call = client.SendLogMessages();
            await call.RequestStream.WriteAsync(message);
            while (await call.ResponseStream.MoveNext()) //Error happens 
here
            {
                var newMessage = call.ResponseStream.Current;
                await Application.Current.Dispatcher.BeginInvoke(new Action
(() =>
                {
                    rtb.AppendText(newMessage.Message);
                    rtb.AppendText(Environment.NewLine);
                }), DispatcherPriority.Background);
            }
        }
    }
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();


            Thread thread = new Thread(Connect);
            thread.Start();
        }


        private void Connect()
        {
            try
            {
                Logger.LogMessage message = new Logger.LogMessage();
                message.ClientType = 1;
                message.Message = "connecting";


                Channel channel = new Channel("192.168.1.223", 50051, 
ChannelCredentials.Insecure);


                LogClient client = new LogClient(new Logger.Logger.
LoggerClient(channel), rtb);


                client.ConnectAndListenForMessage(message).Wait();
            }
            catch (Exception e)
            {
                Console.Write(e.StackTrace);
            }
        }
    }
}

Does anyone know what the issue is?

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to grpc-io+unsubscr...@googlegroups.com.
To post to this group, send email to grpc-io@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/210a8d96-2e98-4290-8aa7-6d573a1106b0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to