Questions on Setting up a TTN Backend Network Server Development Environment


(Hoon Park) #1

Hi @johan,

I have a few questions regarding setting up a TTN backend network server development environment as follows:

[1]. Instruction for setting up the development environment

There are two source code trees as below:
(1) v1-staging : https://github.com/TheThingsNetwork/ttn/tree/v1-staging
(2) v2-preview : https://github.com/TheThingsNetwork/ttn/tree/v2-preview

I guess v1-staging is what we are currently using and v2-preview is the production version that's planned to be released in December this year. Am I right?

I guess v2-preview is currently under development and the code will be changing every day, and there is no code change for v1-staging.

Due to this reason, I'd like to set up the development environment and compile v1-staging first before I try to compile v2-preview.

I see there is an instruction for setting up for v2-preview but there is no set up instruction for v1-staging. Does the instruction for v2-preview apply to v1-staging?

[2] Which OS and version?
Which Linux version is preferred for the development environment? Is Ubuntu preferred? If it is, is the latest version of Ubuntu ok?

[3] Go lang and other component versions

I need to download and set up these components - Go, protobuf compiler, Redis, RabbitMQ - according to the instruction. I assume I should download the latest version of these components. Am I right?

[4] To run TTN network server locally

According to the instruction, I am supposed to run 'forego start' to start all backend services at the same time.

Can I start each TTN server component separately such as 'ttn router', 'ttn broker', 'ttn networkserver', 'ttn handler'?

[5] Configuration file for each TTN server component?

If I ran TTN router, broker, handler, and network server separately on different hardware (with different IP addresses), I should configure these components with correct IP addresses so they can talk to right counterparts. Is there a configuration file for each TTN server component?

Thanks.


(Hylke Visser) #2

Hi @hoonppark,

Great to hear that you want to help us with the development of the backend. The instructions for setting up your environment can be found on Github. We use Linux or macOS machines, but Windows should be possible too (although you'd have to figure that out yourself).

v1-staging is what's currently running on staging.thethingsnetwork.org, while v2-preview is the code for the upcoming version that is running our preview environment. We don't do development on v1-staging anymore and it will be discontinued after we officially launch v2, so it would be a waste to spend your time on that.

Using the latest stable versions of dependencies will probably give the best experience, but any recent version should work just fine too.

If you look in the Procfile you see what commands forego runs in order to start each component. You can run these commands separately as well.

You can find the configuration files for your development environment in the .env folder. The configuration in those files should be enough to start development of the backend. You can "simulate" running the components on different machines by using the docker-compose file that is included in the repository (just follow the part about Docker in the README).


(Hoon Park) #3

Thanks for the info, @htdvisser. I'll try to set up for v2-preview on Linux.

Is v2-preview planned to be released to production by the end of December this year?

Which Linux is preferred by the TTN development team for the TTN Network Server development environment?

And, for the OS platform for the current staging server and v2 production TTN Network Server, are you using CentOS and/or plan to use CentOS?


(Hylke Visser) #4

Yes, we're planning to remove the preview suffix from v2 before the end of December.
We don't have any opinion on Linux distributions; neither for development, nor for production machines, so just take what you're most comfortable with.


(Hoon Park) #5

According to the instructions for setting up the TTN server development environment, Redis needs to be installed and running on a development machine. (Probably on a deployment machine too, right? )

On Redis download page, it states 'Redis 3.2 contains significant changes to the API and implementation of Redis.'

Which version of Redis do I need to install for the TTN Network Server?

@htdvisser, do you have any comment on this?


(Hylke Visser) #6

You can always assume that we run the latest versions of our dependencies. We only use a small subset of the Redis API, so an older version should work just as well, but I usually prefer the latest.


(Hoon Park) #7

Ok. Thanks.

It gives me the info I'd like to know.


#8

I have compiled the ttn-2-preview version from the source. I have first started my discovery server, then I try to start router, but I get this error message: FATAL Could not initialize router error=Failed to announce this component to TTN discovery: rpc error: code = 2 desc = permission denied: unable to parse token: Auth server dev not registered: permission denied: unable to parse token: Auth server dev not registered. Can you help me with that? :slight_smile:


#9

you need to use the TTN account server, unless you have developed your own


#10

Thanks, now it is working, but my router does not open a port for uplink stream for my gateway. Does any body know how to do that? I have tried to change the configure file for the router, but that does not work for me. :confused:


#11

you dont need open ports ... it opens a 2way session over NAT just fine.


#12

I don't mean a physical router, but I mean ttn router. I don't see any udp port which is open on my server
that I can configure my gateway to send packages to that port (by default it is 1700). :slight_smile:


(Hoon Park) #13

@sPyLoRa, read this posting for the answer.

Basically, you need to run the lora-gateway-bridge between a gateway (a current version gateway sending udp packets to the ttn-router) and the ttn-router of the v2-preview TTN Network Server.


#14

@hoonppark do you know how to start a ttn handler, because when I start a ttn handler then the port 1782 doesn't opened. Therefore I can't run ttnctl on my local server. :slight_smile:


(Hoon Park) #15

@sPyLoRa, I haven't tried to start a ttn router alone yet. I just ran 'forego start' to start all ttn server components. Once I run the command '$ forego start', I can see the following ttn processes are started:

ubuntu:~$ ps -ef | grep ttn
hoon 33436 33427 0 09:49 ? 00:00:00 ttn router --config ./.env/router/dev.yml --health-port 10901
hoon 33440 33427 0 09:49 ? 00:00:00 ttn discovery --config ./.env/discovery/dev.yml --health-port 10900
hoon 33441 33427 0 09:49 ? 00:00:00 ttn networkserver --config ./.env/networkserver/dev.yml --health-port 10903
hoon 33453 33427 0 09:49 ? 00:00:00 ttn broker --config ./.env/broker/dev.yml --health-port 10902
hoon 33459 33427 0 09:49 ? 00:00:00 ttn handler --config ./.env/handler/dev.yml --health-port 10904

As you can see, 'ttn router' is reading the configuration info from the '$TTN_SOURCE_ROOT_DIR/.env/router/dev.yml' file.

The content of the 'dev.yml' file shows the following:

id: dev
debug: true
discovery-address: "localhost:1900"
auth-servers:
ttn-account: "https://account.thethingsnetwork.org"
ttn-account-preview: "https://preview.account.thethingsnetwork.org"
ttn-account-staging: "https://preview.account.thethingsnetwork.org"
tls: true
key-dir: "./.env/router/"
router:
skip-verify-gateway-token: true

Interestingly, there is no port number mentioned in this file.

Why don't you try to start the TTN server by running the command 'forego start' and see if your server starts up ok. I think that's the first step to verify if your TTN server can start up without a problem or not. Once it works, then try to start each component individually.


(Hylke Visser) #16

Looks like you're using the v1-staging version of ttnctl while using the v2-preview version of the backend. Try updating everything to the latest version.


#17

If I use v2-preview version of ttnctl to login then I get error like FATAL Login failed error=Code not found. :confused:


(Hoon Park) #18

Are you using a v2-preview ttnctl you compiled? Or, are you using one you downloaded from the TTN site?


#19

I'm using a v2-preview ttnctl that I compiled.