Question: How to connect to server?
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.
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.CloudStorageor anything that initializes a connection, setTrinityConfig.CurrentRunningMode = RunningMode.Client;-- this is the classical way of setting up a client. Also, if you haveFanoutSearch, the module has an option to force initialization as a client. - A more modern approach is to use the
GraphEngine.Clientpackages. It's still WIP but we're able to do something likeTrinityClient 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.
Ok, what i managed to do so far is the following.
- declared a comm. module by describing in TSL + protocol definitions
module SimpleServerCommunicationModule
{
protocol AddSimpleNodeProtocol;
protocol GetSimpleNodeProtocol;
}
- created a simple comm module implementation
- 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();
}
}
- 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.