Skip to content
This repository has been archived by the owner on Oct 28, 2022. It is now read-only.

Does GNMIC support multiple sessions to Server within the same connection ?? #644

Open
shivamganwani opened this issue Sep 16, 2022 · 15 comments

Comments

@shivamganwani
Copy link

Hi,
I am testing this telemetry app with GNMIC and I am able to do the subscribe and capabilities request. I am getting the expected output but here I am only creating one gnmi session.
Is there a way to make multiple sessions within the same connection. Can I add something to the config file of GNMIC to support multiple sessions.

Currently my config file looks like :
**insecure : false
log : true
username : dial
password : Dial@123

tunnel-server:
address: ":50056"
target-wait-time: 20s
skip-verify: false
cert-file: "/root/shivam/self-signed.crt"
key-file: "/root/shivam/self-signed.key"
debug: false**

@karimra
Copy link
Owner

karimra commented Sep 21, 2022

Hi,

Can you describe a bit more what kind of sessions you are trying to create (which RPC)?
I see that your config file has tunnel-server config, are you trying to use gNMIc as a tunnel server?

@shivamganwani
Copy link
Author

Hi,

Yes I am using gNMIc as a tunnel server. Ok I'll explain you a bit about tunnelclient on the other side. So whenever a connection is made tunnelclient accepts a tag-id from gNMIc and creates a new single session. I want to send multiple tag-id's to tunnelclient in parallel so that multiple GNMI sessions are created at once.

@karimra
Copy link
Owner

karimra commented Sep 21, 2022

To create a session you have to trigger an RPC, can you share which RPCs you want to send to the server on the other side of the tunnel?

@mankhakb
Copy link

Hi,

Here gNMIC we are using as a tunnel server.
On the other side we are running tunnel client.
https://github.com/openconfig/grpctunnel/blob/master/proto/tunnel/tunnel.proto
Using tunnel rpc, tunnel server and tunnel client will exchange streaming data(gnmi request and response).
This streaming data can be subscribe, capability, set or get request/response.
Tunnel server(gNMIC) will send the request and gnmi server which is running behind the tunnel client sends response via streaming tunnel to tunnel server.

Here concurrent gnmi session can be possible with in the same streaming tunnel.
From the tunnel.proto unique tag is to differentiate between gnmi session.

So here the ask is does gNMIC support multiple sessions using the same streaming tunnel.

Thanks
Manish Khandelwal

@shivamganwani
Copy link
Author

Hi @karimra,

Did the above comment answer your query ?

@karimra
Copy link
Owner

karimra commented Sep 21, 2022

I understand that, that is basically the spec of grpc tunnel.
Yes gnmic support multiple sessions.

What I'm asking is which rpc you want to trigger (streaming, unary) and how (are you running gnmic as a cli? as a daemon)?
In both cases, how do expect to trigger multiple RPCs?

The way to create multiple sessions depends on the type of RPC and how gnmic is ran.

@karimra
Copy link
Owner

karimra commented Sep 21, 2022

@shivamganwani
Copy link
Author

Ok thanks for the link, I am going thru it.
Just giving some info:
We already have a fully implemented gnmi server with subscribe, capabilities RPCs, etc.
I have already tested by sending a subscribe and capability request to our gnmi server and things are working perfectly.

Just to be sure, in this link -> "Combining Tunnel server with a gNMI server" -
Will this help if we are using our own gnmi server or this is only helpful if we want to use gNMIc's gNMI server ?

@karimra
Copy link
Owner

karimra commented Sep 21, 2022

Your gNMI server is separate.
The link shows how to use gNMIc as both a Tunnel Server and a gNMI server.
This allows you to interact with gNMIc using another client, gNMIc will "proxy" the requests received on its gNMI Server through the gRPC tunnel to your gNMI server.
Hopefully this diagram helps:
image

@shivamganwani
Copy link
Author

Hi @karimra

I am not sure if the link you posted is related to my requirement but I might be wrong. Anyways I have tried to explain the entire architecture and attached ss of issue, please have a look once. Sorry for making it so long :p

I am running a streaming RPC (which is subscribe).
gNMIc runs as a tunnel server (you already know about that) as a DAEMON. I mean I run the binary and give it a long timeout and so gNMIc waits for any configuration to be done on my network element, once configuration is done the connection between network element and gNMIc is initiated.
So you said that YES gNMIc supports multiple sessions. Now just to be sure that we both are talking about the same requirement (i.e., our understanding of sessions is same or not).
I want to make 2 parallel sessions with the same tunnel.
Right now I make only one session with a tunnel and tag id of the session is 1. But now I want to make multiple of these sessions with unique tag ids.
So to summarize if you think in terms of a black box. I want to tweak the config file which I am passing in such a way that instead of 1 session it creates 2 parallel sessions with different tag ids and both these can be subscribe requests.

Please see this for things to be more clear:
Setup : I have started gNMIc twice and now I want streaming to happen on both but what I see is that streaming happens on the first one but on the second one I get "[gnmic] failed to start gRPC tunnel server listener: listen tcp :50056: bind: address already in use". Please note that I have to make port same. I was expecting that it will connect twice and make 2 sessions.
But this did not happen.
Attaching two screenshots of gNMIc running twice
Screenshot (392)
Screenshot (393)

Now to explain the same thing in a diagram

image

Thanks for all your help, please let me know if anything else need clarification. I will try my best to make things clear.

@karimra
Copy link
Owner

karimra commented Sep 22, 2022

It's not possible for 2 processes to listen the same IP/port on the same host, you will have to change either the IP address or the port for one of the gNMIc instances you are starting. In which case, your client should be configured to establish 2 tunnels.

The session I'm talking about is the one established by the tunnel server (gNMIc) to the tunnel client aimed at a specific target (ID, Type) i.e the gNMI server behind the tunnel client.
The session establishment direction in your diagram should be inverted, the Tunnel is established from client to server while the session is established from server to client as per this use case: https://github.com/openconfig/reference/blob/master/rpc/gnmi/gnmignoissh-dialout-grpctunnel.md#tunnel-server-to-tunnel-client-session-establishment

In the case of Subscribe RPC, a single session is used to carry all the RPCs per target (ID, Type). If you want to establish multiple sessions, you will need to have more than one target behind the tunnel client.
There is no advantage (and some disadvantages) using a session per RPC towards the same target;
Each session will essentially create a gRPC connection to the target behind the tunnel client, so you will end up with one gRPC connection per gNMI subscribe RPC.

In the case of a Unary RPC, each RPC creates its own session towards the tunnel client to reach the target (ID, Type).

@shivamganwani
Copy link
Author

Ok I agree that in the diagram the direction of session arrow is inverted. But that's not the main point I was trying to discuss.

image

I think if I ask you this question things will get clearer :
So you said that there is no point of making multiple gRPC session with same target. Ok I agree. But what if I want to make a gRPC session and netconf session to the same target. As shown in diagram.

@shivamganwani
Copy link
Author

A question related to code of GNMIC :

Reading the code I was expecting that you will be creating a session using the function TunnelSession() [ Line 95 in api/tunnel.go ].
But none of the logs I printed in this function are getting printed when I make a connection with target. Can you explain why is that ? You must be creating a session right ?

@karimra
Copy link
Owner

karimra commented Sep 27, 2022

Ok I agree that in the diagram the direction of session arrow is inverted. But that's not the main point I was trying to discuss.

image

I think if I ask you this question things will get clearer : So you said that there is no point of making multiple gRPC session with same target. Ok I agree. But what if I want to make a gRPC session and netconf session to the same target. As shown in diagram.

A target is identified with both its ID and Type, that why I always write (ID,Type). So in the case of a gRPC and netconf sessions, there should be 2 targets registered; (ID, GNMI_GNOI) and (ID, SSH)

@karimra
Copy link
Owner

karimra commented Sep 27, 2022

A question related to code of GNMIC :

Reading the code I was expecting that you will be creating a session using the function TunnelSession() [ Line 95 in api/tunnel.go ]. But none of the logs I printed in this function are getting printed when I make a connection with target. Can you explain why is that ? You must be creating a session right ?

That part of the code is used to craft the messages, you can use that to write your own tunnel server. I don't use it to write gNMIc's tunnel server. I use https://github.com/openconfig/grpctunnel

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants