1.45.0-alpha.0 • Published 4 years ago

@hoprnet/hopr-server v1.45.0-alpha.0

Weekly downloads
1
License
GPL-3.0-only
Repository
github
Last release
4 years ago

Table of Contents

Overview

HOPR Server functions as a wrapper for a HOPR Node. Upon start, it will automatically spin a HOPR Node listening to port 9091 and create a gRPC-ready interface listening to port 50051 which automatically connects to the HOPR Network using the BOOTSTRAP_SERVERS defined.

To interact with HOPR Server, you need to use HOPR Protos, the Protobuf implementation of the HOPR Protocol which exposes its API via gRPC. HOPR Protos can be installed and used via nom by installing the distribution package.

Technologies

Getting Started

To get a local copy up and running follow these simple steps. In case you just want to have a runnable version of HOPR Server, you can use our Docker Image to quickly start the server.

Prerequisites

This is an example of how to list things you need to use the software and how to install them.

Installation

  1. Clone the repo
git clone https://github.com/hoprnet/hopr-server.git
  1. Install NPM packages
yarn

Docker Image

Pull latest version

docker pull gcr.io/hoprassociation/hopr-server

Run latest version

docker run -p 50051:50051 -p 9091:9091 -it gcr.io/hoprassociation/hopr-server

Run latest version w/specific BOOTSTRAP_SERVERS

docker run \
  -p 50051:50051 -p 9091:9091 \
  -e BOOTSTRAP_SERVERS=/ip4/34.65.75.45/tcp/9091/p2p/16Uiu2HAm2cjqsDMmprtN2QKaq3LJrq3YK7vtdbQQFsxGrhLRoYsy,/ip4/34.65.177.154/tcp/9091/p2p/16Uiu2HAm9C4oJPeRkdXnYxtXzFpDqpcCbWLsgNW4irrCLZTJ7cBd \
  -it gcr.io/hoprassociation/hopr-server

Usage

Upon installing, you can run yarn start to start the server which will use ts-node. Once you see :: HOPR Core Node Started ::, it means that the server has successfully connected to the HOPR Network using the defined BOOTSTRAP_SERVERS and is ready to accept requests.

In case you are looking to distribute the application, you can precompile it using yarn build, which will compile the nest.js TypeScript files and create a dist folder, which can then be used by node directly.

Commands

  1. yarn start - Starts HOPR Server in dev mode.
  2. yarn build - Builds HOPR Server for production.

For more information about the HOPR Network, please refer to the Documentation

Environment Variables

The following environment variables can be stored and used in an .env file located at the root of the project.

NameDescriptionTypeExample
SERVER_HOSTserver HOST urlstring0.0.0.0:50051
DEBUG_MODEpassed to hopr-core: run in debug modebooleanTRUE
IDpassed to hopr-core: demo account IDinteger1
BOOTSTRAP_NODEpassed to hopr-core: TRUE if node is a boostrap nodebooleanFALSE
CORE_HOSTpassed to hopr-core: hopr-core HOST urlstring0.0.0.0:9091
BOOTSTRAP_SERVERSpassed to hopr-core: a list of bootstap server to connect toarray of stringssrc
PROVIDERpassed to hopr-core: blockchain endpointstringwss://kovan.infura.io/ws/v3/f7240372c1b442a6885ce9bb825ebc36

Roadmap

See the issues for a list of proposed features (and known issues).

Additional Information

Query the server using BloomRPC (Recommended)

  1. Download and install BloomRPC.
  2. Download the .proto files that are used by our server.
  3. Import .proto files by clicking on the top-left + icon and navigating to previously downloaded files.
  4. Set the server url in the input at top-center to 127.0.0.1:50051

Quering

  1. Select on of the unary methods from the left panel, for example: version.proto -> version.Version -> GetVersion
  2. Click "play" (▶️), you should get a response of something like:
{
  "components_version": {
    "0": "@hoprnet/hopr-core,0.6.21",
    "1": "@hoprnet/hopr-core-connector-interface,1.3.2-35127fb",
    "2": "@hoprnet/hopr-core-ethereum,0.0.12-refactor.473415f",
    "3": "@hoprnet/hopr-utils,0.1.7-c598e77",
    "4": "@hoprnet/hopr-core-connector-interface,1.3.2-35127fb"
  },
  "version": "0.0.1"
}

Sending & Listening to messages

In this example, you will need to run two servers (server A and server B), one for sending a message and another for listening. Server B needs to be setup in a different directory from server A, as a HOPR Node creates a db directory which can not be shared between different instances.

  1. Start server A: yarn start
  2. Start server B: SERVER_HOST=0.0.0.0:50052 CORE_HOST=0.0.0.0:9092 yarn start
  3. Call GetStatus for both servers using BloomRPC, take note of their ids
  4. Call Listen on server B, peer_id is optional and can be removed, example input: {}
  5. Call Send on server A, example input can be:
{
  "peer_id": "<server B peer ID>",
  "payload": [104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]
}
  1. Server B should have received the message as a payload.

Querying the server using gCURL

  1. Install gCURL using npm install -g gcurl or yarn global add curl.
  2. Start the server yarn start
  3. Wait until terminal displays :: HOPR Core Node Started ::
  4. Call getStatus using gcurl -f ./node_modules/@hoprnet/hopr-protos/protos/status.proto --host 127.0.0.1:50051 --input '{}' --short status:Status:getStatus
  5. First getStatus call might take a minute to respond, you should receive a minified json response like:
{
  "id": "16Uiu2HAm6rVeEmviiSoX67H5fqkTQq2ZyP2QSRwrmtEuTU9pWeKj",
  "multi_addresses": [
    "/ip4/93.109.190.135/tcp/9091/p2p/16Uiu2HAm6rVeEmviiSoX67H5fqkTQq2ZyP2QSRwrmtEuTU9pWeKj",
    "/ip4/192.168.178.33/tcp/9091/p2p/16Uiu2HAm6rVeEmviiSoX67H5fqkTQq2ZyP2QSRwrmtEuTU9pWeKj",
    "/ip4/172.17.2.177/tcp/9091/p2p/16Uiu2HAm6rVeEmviiSoX67H5fqkTQq2ZyP2QSRwrmtEuTU9pWeKj",
    "/ip4/127.0.0.1/tcp/9091/p2p/16Uiu2HAm6rVeEmviiSoX67H5fqkTQq2ZyP2QSRwrmtEuTU9pWeKj"
  ],
  "connected_nodes": 11,
  "cpu_usage": 0
}

Considerations

  • BloomRPC will sometimes insert default input data when calling certain methods, for example with Send it will insert:
{
  "peer_id": "316a50f5-4801-4065-bb73-5c602d594ccf",
  "payload": {
    "type": "Buffer",
    "data": [72, 101, 108, 108, 111]
  }
}

which is incompatible with our server, the right input is:

{
  "peer_id": "16Uiu2HAm6rVeEmviiSoX67H5fqkTQq2ZyP2QSRwrmtEuTU9pWeKj",
  "payload": [104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]
}
  • Before calling Send you should call GetStatus, as the HOPR node might need to “discover” the other node from the network before it is able to send a message. Avoiding to do so might result in a Timeout error.

Links

Contributors

This project has been possible thanks to the support of the following individuals:

Contact

1.43.0-alpha.0

4 years ago

1.44.0-alpha.0

4 years ago

1.45.0-alpha.0

4 years ago

1.42.0-alpha.0

4 years ago

1.40.0-alpha.0

4 years ago

1.41.0-alpha.0

4 years ago

1.39.0-alpha.0

4 years ago

1.38.0-alpha.0

4 years ago

1.17.19

4 years ago

1.37.0-alpha.0

4 years ago

1.36.0-alpha.0

4 years ago

1.35.0-alpha.0

4 years ago

1.33.0-alpha.0

4 years ago

1.34.0-alpha.0

4 years ago

1.31.0-alpha.0

4 years ago

1.17.18

4 years ago

1.32.0-alpha.0

4 years ago

1.29.0-alpha.0

4 years ago

1.30.0-alpha.0

4 years ago

1.28.0-alpha.0

4 years ago

1.27.0-alpha.0

4 years ago

1.17.17

4 years ago

1.25.0-alpha.0

4 years ago

1.26.0-alpha.0

4 years ago

1.17.15

4 years ago

1.17.16

4 years ago

1.17.11

4 years ago

1.17.14

4 years ago

1.17.13

4 years ago

1.17.12

4 years ago

1.24.0-alpha.0

4 years ago

1.17.10

4 years ago

1.23.0-alpha.0

4 years ago

1.17.9

4 years ago

1.17.8

4 years ago

1.22.0-alpha.0

4 years ago

1.17.7

4 years ago

1.21.0-alpha.0

4 years ago

1.17.6

4 years ago

1.17.5

4 years ago

1.20.0-alpha.0

4 years ago

1.19.0-alpha.0

4 years ago

1.17.2-alpha.0

4 years ago

1.17.4

4 years ago

1.17.3

4 years ago

1.18.0-alpha.0

4 years ago

1.17.2

4 years ago

1.17.1

4 years ago

1.17.0

4 years ago

1.17.0-alpha.75

4 years ago

1.17.0-alpha.76

4 years ago

1.17.0-alpha.74

4 years ago

1.17.0-alpha.68

4 years ago

1.17.0-alpha.69

4 years ago

1.17.0-alpha.67

4 years ago

1.17.0-alpha.71

4 years ago

1.17.0-alpha.72

4 years ago

1.17.0-alpha.70

4 years ago

1.17.0-alpha.73

4 years ago

1.17.0-alpha.66

4 years ago

1.17.0-alpha.65

4 years ago

1.17.0-alpha.64

4 years ago

1.17.0-alpha.63

4 years ago

1.17.0-alpha.62

4 years ago

1.17.0-alpha.61

4 years ago

1.17.0-alpha.60

4 years ago

1.17.0-alpha.59

4 years ago

1.17.0-alpha.57

4 years ago

1.17.0-alpha.58

4 years ago

1.17.0-alpha.56

4 years ago

1.17.0-alpha.55

4 years ago

1.17.0-alpha.54

4 years ago

1.17.0-alpha.53

4 years ago

1.17.0-alpha.51

4 years ago

1.17.0-alpha.52

4 years ago

1.17.0-alpha.46

4 years ago

1.17.0-alpha.47

4 years ago

1.17.0-alpha.48

4 years ago

1.17.0-alpha.49

4 years ago

1.17.0-alpha.50

4 years ago

1.17.0-alpha.44

4 years ago

1.17.0-alpha.45

4 years ago

1.17.0-alpha.43

4 years ago

1.17.0-alpha.42

4 years ago

1.17.0-alpha.40

4 years ago

1.17.0-alpha.41

4 years ago

1.17.0-alpha.39

4 years ago

1.17.0-alpha.38

4 years ago

1.17.0-alpha.36

4 years ago

1.17.0-alpha.37

4 years ago

1.17.0-alpha.35

4 years ago

1.17.0-alpha.24

4 years ago

1.17.0-alpha.25

4 years ago

1.17.0-alpha.22

4 years ago

1.17.0-alpha.23

4 years ago

1.17.0-alpha.28

4 years ago

1.17.0-alpha.29

4 years ago

1.17.0-alpha.26

4 years ago

1.17.0-alpha.27

4 years ago

1.17.0-alpha.20

4 years ago

1.17.0-alpha.21

4 years ago

1.17.0-alpha.33

4 years ago

1.17.0-alpha.34

4 years ago

1.17.0-alpha.31

4 years ago

1.17.0-alpha.32

4 years ago

1.17.0-alpha.30

4 years ago

1.17.0-alpha.19

4 years ago

1.17.0-alpha.13

4 years ago

1.17.0-alpha.14

4 years ago

1.17.0-alpha.12

4 years ago

1.17.0-alpha.18

4 years ago

1.17.0-alpha.15

4 years ago

1.17.0-alpha.16

4 years ago

1.17.0-alpha.11

4 years ago

1.17.0-alpha.10

4 years ago

1.17.0-alpha.1

4 years ago

1.17.0-alpha.9

4 years ago

1.17.0-alpha.0

4 years ago

0.4.0

4 years ago

0.2.5-xdai

4 years ago

0.2.4-xdai

4 years ago

0.3.0

4 years ago

0.2.0

4 years ago

0.2.3-xdai

4 years ago

0.2.2-xdai

4 years ago

0.2.1-xdai

4 years ago

0.2.0-xdai

4 years ago

0.1.0

4 years ago

0.0.5

4 years ago

0.0.3

4 years ago

0.0.4

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago