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

Working with several servers machines #12

Closed
4br3mm0rd opened this issue Apr 16, 2020 · 7 comments
Closed

Working with several servers machines #12

4br3mm0rd opened this issue Apr 16, 2020 · 7 comments

Comments

@4br3mm0rd
Copy link

Hi everyone!

I am working in an environment with separate machines for the Chirpstack Network Server, Application Server, and the Device Simulator. I am trying to send a Join Request using the following configuration.

encoded_type = []
log_level = ""

[mqtt]
  server = "tcp://lora-ns:1883"
  user = ""
  password = ""
  downlink_topic = "gateway/abcdabcdabcdabcd/event"
  uplink_topic = "gateway/abcdabcdabcdabcd/command"

[forwarder]
  nserver = ""
  nsport = ""

[band]
  name = "US_902_928"

[device]
  eui = "1111111111111111"
  address = "22222222"
  network_session_encription_key = "33333333333333333333333333333333"
  serving_network_session_integrity_key = "44444444444444444444444444444444"
  forwarding_network_session_integrity_key = "55555555555555555555555555555555"
  application_session_key = "66666666666666666666666666666666"
  marshaler = "protobuf"
  nwk_key = "22222222222222222222222222222222"
  app_key = "76757279736563726574"
  join_eui = "0000000000000000"
  mac_version = 0
  profile = "ABP"
  joined = false
  skip_fcnt_check = true

[gateway]
  mac = "abcdabcdabcdabcd"
  bridge_version = ""

[data_rate]
  bandwith = 125
  spread_factor = 7
  bit_rate = 0

[rx_info]
  channel = 0
  code_rate = ""
  crc_status = 0
  frequency = 0
  lora_snr = 0.0
  rf_chain = 0
  rssi = 0

[raw_payload]
  payload = ""
  use_raw = false
  script = "\n// Encode encodes the given object into an array of bytes.\n//  - fPort contains the LoRaWAN fPort number\n//  - obj is an object, e.g. {\"temperature\": 22.5}\n// The function must return an array of bytes, e.g. [225, 230, 255, 0]\nfunction Encode(fPort, obj) {\n\treturn [];\n}\n"
  use_encoder = false
  max_exec_time = 100
  js_object = ""
  fport = 0

[redis]
  addr = ""
  password = ""
  db = 0

[window]
  width = 1200
  height = 1000

[provisioner]
  hostname = ""
  username = ""
  password = ""
  path = ""
  Token = ""

Where:

  • lora-ns is set in /etc/hosts as the IP for the Network Server, and mqtt is configured to listen on port 1883.
  • On the device part, the device EUI, address, and Session keys are the ones that I chose on the Application Server.
  • The App key is the one that I set in the Application Server configuration.
  • I set ABP in the device profile.

For some reason, I can see the message arrive to the mqtt on the Network server, but I do not see the Network Server handle it, and the message is not forwarded to the Application Server.

I also have a few questions:

  • How should I should the marshaler? Should I set it somewhere on the Network Server part?
  • How can I know the Network Key and the Join EUI? Where is it referenced?

I hope you can help me (or redirect me to some relevant documentation)!

Thank you very much!

@scartill
Copy link
Collaborator

For Version 1.0 case (mac_version = 0 in config) you need:

ABP case:

  • Device EUI (eui in config, Device EUI in Chirpstack)
  • Device address (address in config, Device address in Chirpstack)
  • NwkSEncKey (network_session_encription_key in config, Network session key in Chirpstack)
  • AppSKey (application_session_key in config, Application session key in Chirpstack)

OTAA case:

  • Device EUI (eui in config, Device EUI in Chirpstack)
  • NwkKey (nwk_key in config, Application key in Chirpstack)

You can take a look here: https://github.com/iegomez/lds/blob/master/device.go#L46

Marshaller is all about application payload, it is not involved in ABP/OTAA processes.

Please feel free to ask futher questions (or just close the issue).

Hope this helps

@4br3mm0rd
Copy link
Author

Thank you very much for your answer, I've been having a hard time with this for a few weeks now...

I have tried to set it on a single machine (all the servers on one machine, as chirpstack's starter guide suggests) so that I'm not supposed to face any configuration issues on the server-side theoretically, trying both OTAA and ABP (with your suggested parameters - and the other parameters with dummy values, because otherwise, it crashes), but I'm still facing the same issue:

  • I am able to send a join request (it logs: join sent, and the message appears in mosquitto)
  • I do not get any response from the servers...

Here is a screenshot of the logs:
image

Thank you very much for your help

PS: my App and Network servers seem to be working ok (they are actually communicating with each other regularly) - nothing is logged by any of the servers when I send the join request.

@scartill
Copy link
Collaborator

I've recently a bunch of issues in the master branch. Could you please retry with version from #16 pull request?

@4br3mm0rd
Copy link
Author

I just tried with this pull request and the result is the same: the message appears on the mosquitto_sub command, but the network server and application server don't react (no response, no log)

@scartill
Copy link
Collaborator

Could you please provide your configuration files for lds and chirpstack server components? I'll try to reproduce

@4br3mm0rd
Copy link
Author

Sure,
For LDS (using ABP):

encoded_type = []
log_level = ""

[mqtt]
  server = "localhost:1883"
  user = ""
  password = ""
  downlink_topic = "gateway/abababababababab/event"
  uplink_topic = "gateway/abababababababab/command"

[forwarder]
  nserver = ""
  nsport = ""

[band]
  name = "US_902_928"

[device]
  eui = "1111111111111111"
  address = "22222222"
  network_session_encription_key = "33333333333333333333333333333333"
  serving_network_session_integrity_key = "00000000000000000000000000000001"
  forwarding_network_session_integrity_key = "00000000000000000000000000000001"
  application_session_key = "44444444444444444444444444444444"
  marshaler = "json"
  nwk_key = "00000000000000000000000000000001"
  app_key = "00000000000000000000000000000001"
  join_eui = "0000000000000001"
  mac_version = 0
  profile = "ABP"
  joined = false
  skip_fcnt_check = false

[gateway]
  mac = "abababababababab"
  bridge_version = ""

[data_rate]
  bandwith = 125
  spread_factor = 10
  bit_rate = 0

[rx_info]
  channel = 0
  code_rate = ""
  crc_status = 1
  frequency = 916800000
  lora_snr = 7.0
  rf_chain = 1
  rssi = -57

[raw_payload]
  payload = ""
  use_raw = false
  script = "\n// Encode encodes the given object into an array of bytes.\n//  - fPort contains the LoRaWAN fPort number\n//  - obj is an object, e.g. {\"temperature\": 22.5}\n// The function must return an array of bytes, e.g. [225, 230, 255, 0]\nfunction Encode(fPort, obj) {\n\treturn [];\n}\n"
  use_encoder = false
  max_exec_time = 100
  js_object = ""
  fport = 0

[redis]
  addr = ""
  password = ""
  db = 0

[window]
  width = 1200
  height = 1000

[provisioner]
  hostname = ""
  username = ""
  password = ""
  path = ""
  Token = ""

For LDS (OTAA):

encoded_type = []
log_level = ""

[mqtt]
  server = "localhost:1883"
  user = ""
  password = ""
  downlink_topic = "gateway/abababababababab/event"
  uplink_topic = "gateway/abababababababab/command"

[forwarder]
  nserver = ""
  nsport = ""

[band]
  name = "US_902_928"

[device]
  eui = "2222222222222222"
  address = "00000001"
  network_session_encription_key = "00000000000000000000000000000001"
  serving_network_session_integrity_key = "00000000000000000000000000000001"
  forwarding_network_session_integrity_key = "00000000000000000000000000000001"
  application_session_key = "00000000000000000000000000000001"
  marshaler = "json"
  nwk_key = "00000000000000010000000000000001"
  app_key = "00000000000000010000000000000001"
  join_eui = "0000000000000002"
  mac_version = 0
  profile = "OTAA"
  joined = false
  skip_fcnt_check = false

[gateway]
  mac = "abababababababab"
  bridge_version = ""

[data_rate]
  bandwith = 125
  spread_factor = 7
  bit_rate = 0

[rx_info]
  channel = 0
  code_rate = ""
  crc_status = 0
  frequency = 916800000
  lora_snr = 7.0
  rf_chain = 1
  rssi = -57

[raw_payload]
  payload = ""
  use_raw = false
  script = "\n// Encode encodes the given object into an array of bytes.\n//  - fPort contains the LoRaWAN fPort number\n//  - obj is an object, e.g. {\"temperature\": 22.5}\n// The function must return an array of bytes, e.g. [225, 230, 255, 0]\nfunction Encode(fPort, obj) {\n\treturn [];\n}\n"
  use_encoder = false
  max_exec_time = 100
  js_object = ""
  fport = 0

[redis]
  addr = ""
  password = ""
  db = 0

[window]
  width = 1200
  height = 1000

[provisioner]
  hostname = ""
  username = ""
  password = ""
  path = ""
  Token = ""

For the network server (it's the configuration file located in /etc/chirpstack-network-server/chirpstack-network-server-us-us915.toml with the updated password for postgres):

[postgresql]
dsn="postgres://chirpstack_ns:********@localhost/chirpstack_ns?sslmode=disable"

[redis]
url="redis://localhost:6379"

[network_server]
net_id="000000"

  [network_server.band]
  name="US915"
    enabled_uplink_channels=[0, 1, 2, 3, 4, 5, 6, 7]

    [network_server.network_settings.class_b]
    ping_slot_dr=0
    ping_slot_frequency=0

  [network_server.api]
  bind="0.0.0.0:8000"

  [network_server.gateway.backend]
  type="mqtt"

    [network_server.gateway.backend.mqtt]
    event_topic="gateway/+/event/+"
    command_topic_template="gateway/{{ .GatewayID }}/command/{{ .CommandType }}"
    server="tcp://localhost:1883"
    username=""
    password=""


[metrics]
timezone="Local"

[join_server]

  [join_server.default]
  server="http://localhost:8003"

Application Server (it's the configuration suggested in the "getting started" guide of chirpstack:

[general]
log_level=4

[postgresql]
dsn="postgres://chirpstack_as:********@localhost/chirpstack_as?sslmode=disable"

  [application_server.external_api]
  jwt_secret="verysecret"

Thank you very much for your help!

@scartill
Copy link
Collaborator

Hi @4br3mm0rd

You have multiple issues with LDS config:

  • Your uplink and downlink topics are confused, you better keep them to default
  • If you do not use encoder (use_encoder=false and encoded_type=[]), payload shouldn't be empty (payload="").

Try this config:

encoded_type = []
log_level = "debug"

[mqtt]
  server = "localhost:1883"
  user = ""
  password = ""
  # Uplink topic. %s will be replaced with the gateway mac.
  uplink_topic="gateway/%s/event/up"
  # Downlink topic. %s will be replaced with the gateway mac.
  downlink_topic="gateway/%s/command/down"

[forwarder]
  nserver = ""
  nsport = ""

[band]
  name = "US_902_928"

[device]
  eui = "1111111111111111"
  address = "22222222"
  network_session_encription_key = "33333333333333333333333333333333"
  serving_network_session_integrity_key = "00000000000000000000000000000001"
  forwarding_network_session_integrity_key = "00000000000000000000000000000001"
  application_session_key = "44444444444444444444444444444444"
  marshaler = "json"
  nwk_key = "00000000000000000000000000000001"
  app_key = "00000000000000000000000000000001"
  join_eui = "0000000000000001"
  mac_version = 0
  profile = "ABP"
  joined = false
  skip_fcnt_check = false

[gateway]
  mac = "abababababababab"
  bridge_version = ""

[data_rate]
  bandwith = 125
  spread_factor = 10
  bit_rate = 0

[rx_info]
  channel = 0
  code_rate = ""
  crc_status = 1
  frequency = 916800000
  lora_snr = 7.0
  rf_chain = 1
  rssi = -57

[raw_payload]
  payload = "ff00"
  use_raw = false
  script = "\n// Encode encodes the given object into an array of bytes.\n//  - fPort contains the LoRaWAN fPort number\n//  - obj is an object, e.g. {\"temperature\": 22.5}\n// The function must return an array of bytes, e.g. [225, 230, 255, 0]\nfunction Encode(fPort, obj) {\n\treturn [\n      obj[\"Flags\"],\n      obj[\"Battery\"],\n      obj[\"Light\"],\n    ];\n}\n"
  use_encoder = false
  max_exec_time = 500
  js_object = "{\n \"Flags\": 0,\n \"Battery\": 65,\n \"Light\": 54\n}"
  fport = 2


[redis]
  addr = ""
  password = ""
  db = 0

[window]
  width = 1200
  height = 1000

[provisioner]
  hostname = ""
  username = ""
  password = ""
  path = ""
  Token = ""

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

2 participants