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 signal server swarm #27

Open
HerbCaudill opened this issue Oct 14, 2019 · 1 comment
Open

Implement signal server swarm #27

HerbCaudill opened this issue Oct 14, 2019 · 1 comment

Comments

@HerbCaudill
Copy link
Member

randomly select a URL if more than one is provided? select best based on ping?

https://github.com/DevResults/cevitxe/blob/c8f9e8c6676987c5fed42131fd7115a22c9fd12e/packages/core/src/Client.ts#L23-L28


This comment was generated by todo based on a TODO comment in c8f9e8c in #26. cc @DevResults.

Originally posted by @todo in #26 (comment)

@HerbCaudill
Copy link
Member Author

Currently if we see a configuration with more than one URL for signal servers, we just pick the first one.

That's because we don't currently support having more than one signal server per discovery key. (If Alice talks to signal server X and Bob talks to signal server B, they'll never be introduced even if they have the same discovery key.) That's because servers don't know anything about each other.

To support multiple signal servers, I'd like to implement a swarm along these lines:

  • The server starts out with a list of known servers and tries to establish a direct websocket to each.

    • If a connection fails, it retries with exponential decay
  • When any two servers connect, they sync up on an Automerge document containing a directory of known servers, along with the discovery keys that each one handles, and the number of clients currently connected for each.

  • If the latest document contains servers that this server is not connected to, it tries to connect to each one.

  • The client starts out with the same list of known servers, and picks one somehow (randomly, lowest ping, etc.)

    • If a connection fails, the client picks another and tries it
  • When a client connects:

    • The client asks to be introduced to peers for a discovery key
    • If the server knows of another server that has already claimed that discovery key, it refers the client to that server
    • If the server hasn't seen the discovery key before, it claims the discovery key, accepts the client connection, and updates the shared directory document

@HerbCaudill HerbCaudill changed the title Select signal server if more than one is provided Implement signal server swarm Oct 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant