thingsboard / thingsboard-edge

Apache License 2.0
93 stars 71 forks source link

Data was sent from ThingsBoard Gateway but Device is still in inactive mode on ThingsBoard Edge server #96

Closed ktran1005 closed 5 months ago

ktran1005 commented 5 months ago

Component

Description Hello ThingsBoard Edge team, I am implementing a custom connector that can connect to ThingsBoard Gateway and the gateway will send the data to the edge and from the edge to the cloud. I was able to implement a customer connector that can connect to the gateway and they gateway can send the data to the ThingsBoard server directly. I can see the real-time data in the latest telemetry section on ThingsBoard cloud. However, when I tried to send the data to the edge, it seemed like the edge could not receive the data and kept being in inactive mode. I am currently running the edge as a docker container (localhost:8080). I wonder if you guys have any suggestion to fix this issue?hg

docker-compose.yml

version: '3.8'
services:
  mytbedge:
    restart: always
    image: "thingsboard/tb-edge:3.6.2EDGE"
    ports:
      - "8080:8080"
      - "1883:1883"
      - "5683-5688:5683-5688/udp"
    environment:
      SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/tb-edge
      CLOUD_ROUTING_KEY: 
      CLOUD_ROUTING_SECRET: 
      CLOUD_RPC_HOST: demo.thingsboard.io
    volumes:
      - tb-edge-data:/data
      - tb-edge-logs:/var/log/tb-edge
  postgres:
    restart: always
    image: "postgres:15"
    ports:
      - "5432"
    environment:
      POSTGRES_DB: tb-edge
      POSTGRES_PASSWORD: postgres
    volumes:
      - tb-edge-postgres-data:/var/lib/postgresql/data

volumes:
  tb-edge-data:
    name: tb-edge-data
  tb-edge-logs:
    name: tb-edge-logs
  tb-edge-postgres-data:
    name: tb-edge-postgres-data

log of Edge: image

log of GW: service.log Screenshot from 2024-02-09 09-37-31

connector.log Screenshot from 2024-02-09 09-38-36

converter.log Screenshot from 2024-02-09 09-39-28

Environment

volodymyr-babak commented 5 months ago

Hello,

could you please attach docker-compose.yml file to the ticket for the edge service? But please do not forget to remove your access and routing keys. And other sensitive data, if any.

ktran1005 commented 5 months ago

Hi @volodymyr-babak, I included my docker-compose setup in my ticket. I wonder if this is a port conflicted in this case. For some reasons, I was able to ping the thingsboard cloud (data from my device -> thingsboard cloud). But when I tried from my device -> edge -> thingsboard cloud then it did not work

volodymyr-babak commented 5 months ago

Thanks, it looks OK and your MQTT edge port is 1883. Could you please provide host and port of the main GW configuration file? 2024-02-09_15-47

I'm wondering if you are connecting GW to the Edge MQTT API.

ktran1005 commented 5 months ago

Thanks for your response @volodymyr-babak . When I connect my GW to the Edge at the first time, I used port 8080 then it did not work. After that I realized that I was able ping to the thingsboard.cloud with port 1883, therefore I changed my config to connect to the edge with host: localhost or 127.0.0.1 (tried both ways) with port 1883 as well then it still did not work

volodymyr-babak commented 5 months ago

Please provide more details where GW and Edge service are running? Are they running on the same machine or different ones? Are you able from GW machine check if Edge service ports are opened using telnet: telnet EDGE_IP_ADDRESS 1883,

where EDGE_IP_ADDRESS can be localhost, ip address or some hostname.

ktran1005 commented 5 months ago

@volodymyr-babak, I recently changed the port for mqtt in the docker-compose as:

ports:
      - "11883:1883"

Here is the output from terminal when I use telnet command to check if the port is opened Screenshot from 2024-02-09 09-13-53

Here is the output wih port 1883: Screenshot from 2024-02-09 09-18-52

FYI. I am running the GW and Edge services in the same machine

volodymyr-babak commented 5 months ago

Please attach logs of GW and Edge services to the ticket. According to telnet, output is correct.

ktran1005 commented 5 months ago

Hi @volodymyr-babak, I included the logs from GW and edge in my ticket

volodymyr-babak commented 5 months ago

@ktran1005

Thank you for providing the logs. Upon review, I couldn't find any errors either.

Could you please confirm the status of devices on the Edge Web UI? It seems that the gateway is connected without any errors, but I'd like to double-check if the devices are active on the Edge side.

ktran1005 commented 5 months ago

Hi @volodymyr-babak, it actually works now when I changed my port to 11883 for mqtt