microsoft / psi

Platform for Situated Intelligence
https://github.com/microsoft/psi/wiki
Other
529 stars 93 forks source link

Troubles with RemoteImporter #261

Closed AuMilliat closed 1 year ago

AuMilliat commented 1 year ago

We've been trying to get working the remote importer/exporter over a network without success. I don't know if we've missed something or if it's a bug.

At start everything seems fine, like in localhost :

RemoteImporter meta client connected (ID=7a75fe0b-c4cc-4cc6-adb6-682b16328bb8)
RemoteImporter meta update (Name=---, ID=7a75fe0b-c4cc-4cc6-adb6-682b16328bb8)
'Console_Test_Remote.exe' (CLR v4.0.30319: Console_Test_Remote.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Serialization\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
RemoteImporter meta update (Name=System.UInt32, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, ID=7a75fe0b-c4cc-4cc6-adb6-682b16328bb8)
RemoteImporter meta update (Name=Group1, ID=7a75fe0b-c4cc-4cc6-adb6-682b16328bb8)
RemoteImporter meta update (Name=Group2, ID=7a75fe0b-c4cc-4cc6-adb6-682b16328bb8)
RemoteImporter meta update (Name=Group3, ID=7a75fe0b-c4cc-4cc6-adb6-682b16328bb8)
RemoteImporter meta update (Name=Group4, ID=7a75fe0b-c4cc-4cc6-adb6-682b16328bb8)
RemoteImporter meta update (Name=Group5, ID=7a75fe0b-c4cc-4cc6-adb6-682b16328bb8)
'Console_Test_Remote.exe' (CLR v4.0.30319: Console_Test_Remote.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\mscorlib.resources\v4.0_4.0.0.0_fr_b77a5c561934e089\mscorlib.resources.dll'. Module was built without symbols.
Exception thrown: 'System.IO.IOException' in System.Core.dll
An unhandled exception of type 'System.IO.IOException' occurred in System.Core.dll

HRESULT: 0x8007052E

The stacktrace:

   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.Pipes.NamedPipeClientStream.Connect(Int32 timeout)
   at System.IO.Pipes.NamedPipeClientStream.Connect()
   at Microsoft.Psi.Remoting.NamedPipesTransport.Connect(String host) in D:\\psi\\Sources\\Runtime\\Microsoft.Psi\\Remoting\\Transport\\NamedPipesTransport.cs:line 71
   at Microsoft.Psi.Remoting.RemoteImporter.StartDataClient(Guid id, ITransport transport) in D:\\psi\\Sources\\Runtime\\Microsoft.Psi\\Remoting\\RemoteImporter.cs:line 258
   at Microsoft.Psi.Remoting.RemoteImporter.MetaClientBackground() in D:\\psi\\Sources\\Runtime\\Microsoft.Psi\\Remoting\\RemoteImporter.cs:line 238
   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()
sandrist commented 1 year ago

Hello, it would be helpful if you could share your code, at least the parts where you setup the remote importer and exporter components. How are they configured in your application?

Another quick thing to check is your Windows firewall settings. Make sure your application is allowed through the firewall (Public and Private).

AuMilliat commented 1 year ago

Hello, thanks for your time.

For exporter:

            pipeline = Pipeline.Create(enableDiagnostics: true);
            Out1 = pipeline.CreateEmitter<uint>(this, "Group1");
            Out2 = pipeline.CreateEmitter<uint>(this, "Group2");
            Out3 = pipeline.CreateEmitter<uint>(this, "Group3");
            Out4 = pipeline.CreateEmitter<uint>(this, "Group4");
            Out5 = pipeline.CreateEmitter<uint>(this, "Group5");

            exporter = new RemoteExporter(pipeline);
            exporter.Exporter.Write(Out1, "Group1");
            exporter.Exporter.Write(Out2, "Group2");
            exporter.Exporter.Write(Out3, "Group3");
            exporter.Exporter.Write(Out4, "Group4");
            exporter.Exporter.Write(Out5, "Group5");
            pipeline.RunAsync();
            InitializeComponent();

For the importer:

using Microsoft.Psi;
using Microsoft.Psi.Remoting;

// Enabling diagnotstics !!!
Pipeline p = Pipeline.Create(enableDiagnostics: true);

/*** REMOTE IMPORTER ! ***/
RemoteImporter importer = new RemoteImporter(p, ReplayDescriptor.ReplayAll.Interval, "TABLETTE");
Console.WriteLine("connecting");
if (!importer.Connected.WaitOne(-1))
{
    throw new Exception("could not connect to server");
}
Console.WriteLine("connected");

// RunAsync the pipeline in non-blocking mode.
p.RunAsync(ReplayDescriptor.ReplayAllRealTime);
// Wainting for an out key
Console.WriteLine("Press any key to stop the application.");
Console.ReadLine();
// Stop correctly the pipeline.
p.Dispose();

We've tried without firewall and on a local network. I was guessing it's more related to configuration in PSI or something going wrong as the metadata are received.

AshleyF commented 1 year ago

From the trace it appears that the TCP connection is made successfully and stream metadata is transferred (this is over TCP regardless of the data TransportKind). But then it fails to make the data connection. This is over named pipes by default.

Is it possible to try another transport - perhaps TCP (the TransportKind argument to the RemoteExporter ctor)?

AuMilliat commented 1 year ago

It's working with TCP, thanks!

Is it worth dinging on the named pipes exception ?

AshleyF commented 1 year ago

Glad TCP is working!

The named pipes exception HRESULT seems to indicate some authentication or access issue. I think we need to add more useful exception messaging and also may need to add options to configure security descriptors, etc..

AuMilliat commented 1 year ago

Yeah, I'm not familiar with named pipe, I was expecting the usual "run as administrator" on both side would do the job.

I'm closing the issue, thanks for your time!