GraphEngine icon indicating copy to clipboard operation
GraphEngine copied to clipboard

Question: How to connect to server?

Open eosfor opened this issue 7 years ago • 2 comments

Hello colleagues, seems like i missed in all this :)

Say i've got a TSL, which defines a simple protocol and graph nodes and two messages - to add and get a node. I generated a dll file out of it and able to load it into a server instance. So i made a separate process to host this server instance.

Now i want to have a simple powershell client, which will be able to send commands to a server and receive output. So the first question is - how do i connect to a server. where do i specify server ip or host name and port? how do i authenticate against it? do i need to load the same dll into a client?

Thanks.

eosfor avatar May 27 '18 16:05 eosfor

Yes the comm. protocol dll should also be loaded into the client. There are two ways to start a client from PS:

  • Right before you access Global.CloudStorage or anything that initializes a connection, set TrinityConfig.CurrentRunningMode = RunningMode.Client; -- this is the classical way of setting up a client. Also, if you have FanoutSearch, the module has an option to force initialization as a client.
  • A more modern approach is to use the GraphEngine.Client packages. It's still WIP but we're able to do something like TrinityClient client = new TrinityClient("trinity://127.0.0.1:5304"); client.RegisterCommunicationModlue<FanoutSearchModule>(); client.Start(); which is symmetrical with what you do with a server. This will also allow setting up authentication & support for other transports, e.g. grpc.

yatli avatar May 28 '18 03:05 yatli

Ok, what i managed to do so far is the following.

  1. declared a comm. module by describing in TSL + protocol definitions
module SimpleServerCommunicationModule
{
	protocol AddSimpleNodeProtocol;
	protocol GetSimpleNodeProtocol;
}
  1. created a simple comm module implementation
  2. Imported the comm. module to a server side like this
    public class SimpleServer
    {
        public void Start()
        {
            TrinityServer srv = new TrinityServer();
            srv.RegisterCommunicationModule<TrinityClientModule>();
            srv.RegisterCommunicationModule<SimpleCommunicationModule.SimpleCommunicationModule>();
            srv.Start();
        }
    }
  1. imported the comm. module to a client side
            TrinityClient cl = new TrinityClient("localhost:5304");
            cl.RegisterCommunicationModule<SimpleCommunicationModule.SimpleCommunicationModule>();

            cl.Start();

So it seems i now able to connect. But is this a correct way? Will it change?

But i did not try to put any data into the server yet :). Will try soon.

eosfor avatar May 28 '18 07:05 eosfor