Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement mechanism for providing unique ids for json rpc clients #5439

Closed
sleshchenko opened this issue Jun 22, 2017 · 5 comments
Closed

Implement mechanism for providing unique ids for json rpc clients #5439

sleshchenko opened this issue Jun 22, 2017 · 5 comments
Assignees
Labels
kind/enhancement A feature request - must adhere to the feature request template. sprint/current
Milestone

Comments

@sleshchenko
Copy link
Member

sleshchenko commented Jun 22, 2017

Now id is a part of endpoint address and generation of it is a responsibility of the client. But there is not a way to guarantee that different clients generate a unique identifier.

There are few ways to be sure that different clients use unique identifier:

  1. Implement providing identifier from a server when the connection is set up and implement a mechanism to reconnect as existing client. Something like:
  • Client connects to a websocket endpoint;
  • Server establishes connection and send generated id to client;
  • Client receives id and store it;
  • If the connection is interrupted, client reconnects and somehow specify its identifier (like query param or by sending a special message).
  1. Implement rest service that will generate a unique identifier for clients. Then:
  • Client request identifier for itself and store it;
  • Client constructs endpoint path by adding received identifier;
  1. Also we can investigate if we could robustly identify client without any interaction with him, for example getting client's unique identifier from websocket connection session or something like that.

Second way looks like easier to implement but there still is no guarantee that clients will use implemented service for generation of identifiers. And the second approach force clients to use an identifier on another hand first approach provides identifiers just like additional functionality for reconnection and clients don't have to use it.

@sleshchenko sleshchenko added the kind/enhancement A feature request - must adhere to the feature request template. label Jun 22, 2017
@dkulieshov dkulieshov added team/ide sprint/current status/in-progress This issue has been taken by an engineer and is under active development. labels Jul 11, 2017
@benoitf
Copy link
Contributor

benoitf commented Jul 18, 2017

what is the implementation choice that has been picked up ? between choice 1, 2 and 3 ?

@dkulieshov
Copy link

dkulieshov commented Jul 18, 2017

@benoitf It is not yet decided completely, there appeared some technical impediments so we will probably have something in the middle of the first and the second option. I will provide brief spec draft as soon as the prototype will be tested.

@benoitf
Copy link
Contributor

benoitf commented Jul 18, 2017

@dkuleshov thx for the answer, as I noticed that it was in the current-sprint/in-progress I thought it was decided

@dkulieshov
Copy link

dkulieshov commented Jul 26, 2017

Adding brief specification from the PR, there is more info in comment in PR itself

What does this PR do?

This PR provides a new way of interaction between websocket server-side and client-side.

In order to identify a client on server-side to associate with it some processes or data we must have a unique client ID. In previous version client itself was responsible for ID generation and providing to server-side, that approach had its obvious shortcomings.

The new approach rearrange responsibilities in a such way that server-side now have a centralized way of generating a unique identifier, while client can get that identifier and use it for its identification further. The JSON-RPC service at the moment has the following api:

  • method name: websocketIdService/getId
    method params: none
    method result: String
    description: this method must be used by a client in order to get identifier that will also be associated with current websocket session.
    example:

request

{
    "jsonrpc": "2.0",
    "method": "websocketIdService/getId",
    "id": 0
}

response

{
    "jsonrpc": "2.0",
    "result": "529345982734",
    "id": 0
}
  • method name: websocketIdService/setId
    method params: String
    method result: none
    description: this method must be used by a client in order to make the provided client identifier associated with current websocket session
    example:

request

{
    "jsonrpc": "2.0",
    "method": "websocketIdService/setId",
    "params": "529345982734"
}

So briefly the workflow is the following:

  • Initially client has no websocket identifier
  • When it establishes a first websocket connections and the fist websocket session is initialized it calls a corresponding JSON-RPC service (websocketIdService/getId) to get a unique identifier
  • For all further websocket connection establishments (e.g. reconnection, new endpoint, etc.) it must call a corresponding JSON-RPC service (websocketIdService/setId) in order to identify itself in a newly initialized sessions.

Important comment

In the most basic case when a client establishes a connection server side generates a unique ID which is associated with a session and no client interaction is required at all. However if you need to identify the same client for several websocket sessions (for example when you have several endpoints in a single application) you obviously will need some cross-session identifier and for those purposes we have websocket id service.

So answering your question, when client does not call setId it should work just fine within the single websocket session. When client's logic involves several websocket sessions you have to use cross-session ID.

@dkulieshov dkulieshov removed the status/in-progress This issue has been taken by an engineer and is under active development. label Jul 26, 2017
@garagatyi
Copy link

@dkuleshov @sleshchenko Can we close this issue?

@vparfonov vparfonov added this to the 5.16.0 milestone Aug 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement A feature request - must adhere to the feature request template. sprint/current
Projects
None yet
Development

No branches or pull requests

5 participants