named-pipe-wrapper icon indicating copy to clipboard operation
named-pipe-wrapper copied to clipboard

Server stops receiving client messages after an exception occurs

Open jaimestuardo opened this issue 3 years ago • 0 comments

Hello,

I am using this code to receive messages from pipe clients:

      _pipeServer = new NamedPipeServer<CommandServer.Ipc.Message>(CommandServer.Command.PipeServerName);
      _pipeServer.ClientConnected += delegate (NamedPipeConnection<CommandServer.Ipc.Message, CommandServer.Ipc.Message> connection)
      {
          ////
      };
      _pipeServer.ClientDisconnected += delegate (NamedPipeConnection<CommandServer.Ipc.Message, CommandServer.Ipc.Message> connection)
      {
          ////
      };
      _pipeServer.Error += delegate (Exception exception)
      {
          ////
      };
      _pipeServer.ClientMessage += delegate (NamedPipeConnection<CommandServer.Ipc.Message, CommandServer.Ipc.Message> connection, CommandServer.Ipc.Message message)
      {
         ////
      };

Almost all works perfectly. _pipeServer.ClientMessage continues receiving messages from clients, however, when inside ClientMessage an exception occurs and the _pipeServer.Error event is called, server stops receiving client messages.

I tried calling _pipeServer.Start(); again in the Error event, but it did not work.

If I close the server application and start it again, it starts receiving client messages again.

Any help, please?

Thanks Jaime

jaimestuardo avatar Feb 22 '22 15:02 jaimestuardo