Gateway and Device communication error from network to app server

Hi

I am having one strange issue- I could see in gateway bridge and then in network server for gateway stats recieving fine but in application server its not visible.

I could see following continous error in application server logs -

time=“2023-03-07T21:29:30.928615371Z” level=debug msg=“sql query executed” args=“[]” duration=1.517577ms query=“\n\t\tselect\n\t\t\tg.\n\t\tfrom gateway g\n\t\tinner join network_server ns\n\t\t\ton ns.id = g.network_server_id\n\t\twhere\n\t\t\tns.gateway_discovery_enabled = true\n\t\t\tand g.ping = true\n\t\t\tand (g.last_ping_sent_at is null or g.last_ping_sent_at <= (now() - (interval ‘24 hours’ / ns.gateway_discovery_interval)))\n\t\torder by last_ping_sent_at\n\t\tlimit 1\n\t\tfor update"
time=“2023-03-07T21:29:31.93331317Z” level=debug msg=“sql query executed” args=“[]” duration=1.308046ms query="\n\t\tselect\n\t\t\tg.
\n\t\tfrom gateway g\n\t\tinner join network_server ns\n\t\t\ton ns.id = g.network_server_id\n\t\twhere\n\t\t\tns.gateway_discovery_enabled = true\n\t\t\tand g.ping = true\n\t\t\tand (g.last_ping_sent_at is null or g.last_ping_sent_at <= (now() - (interval ‘24 hours’ / ns.gateway_discovery_interval)))\n\t\torder by last_ping_sent_at\n\t\tlimit 1\n\t\tfor update”
time=“2023-03-07T21:29:32.936866292Z” level=debug msg=“sql query executed” args=“[]” duration=1.51027ms query=“\n\t\tselect\n\t\t\tg.\n\t\tfrom gateway g\n\t\tinner join network_server ns\n\t\t\ton ns.id = g.network_server_id\n\t\twhere\n\t\t\tns.gateway_discovery_enabled = true\n\t\t\tand g.ping = true\n\t\t\tand (g.last_ping_sent_at is null or g.last_ping_sent_at <= (now() - (interval ‘24 hours’ / ns.gateway_discovery_interval)))\n\t\torder by last_ping_sent_at\n\t\tlimit 1\n\t\tfor update"
time=“2023-03-07T21:29:33.940045779Z” level=debug msg=“sql query executed” args=“[]” duration=1.243449ms query="\n\t\tselect\n\t\t\tg.
\n\t\tfrom gateway g\n\t\tinner join network_server ns\n\t\t\ton ns.id = g.network_server_id\n\t\twhere\n\t\t\tns.gateway_discovery_enabled = true\n\t\t\tand g.ping = true\n\t\t\tand (g.last_ping_sent_at is null or g.last_ping_sent_at <= (now() - (interval ‘24 hours’ / ns.gateway_discovery_interval)))\n\t\torder by last_ping_sent_at\n\t\tlimit 1\n\t\tfor update”
time=“2023-03-07T21:29:34.943173784Z” level=debug msg=“sql query executed” args=“[]” duration=1.378259ms query=“\n\t\tselect\n\t\t\tg.\n\t\tfrom gateway g\n\t\tinner join network_server ns\n\t\t\ton ns.id = g.network_server_id\n\t\twhere\n\t\t\tns.gateway_discovery_enabled = true\n\t\t\tand g.ping = true\n\t\t\tand (g.last_ping_sent_at is null or g.last_ping_sent_at <= (now() - (interval ‘24 hours’ / ns.gateway_discovery_interval)))\n\t\torder by last_ping_sent_at\n\t\tlimit 1\n\t\tfor update"
time=“2023-03-07T21:29:35.946487761Z” level=debug msg=“sql query executed” args=“[]” duration=1.603167ms query="\n\t\tselect\n\t\t\tg.
\n\t\tfrom gateway g\n\t\tinner join network_server ns\n\t\t\ton ns.id = g.network_server_id\n\t\twhere\n\t\t\tns.gateway_discovery_enabled = true\n\t\t\tand g.ping = true\n\t\t\tand (g.last_ping_sent_at is null or g.last_ping_sent_at <= (now() - (interval ‘24 hours’ / ns.gateway_discovery_interval)))\n\t\torder by last_ping_sent_at\n\t\tlimit 1\n\t\tfor update”
time=“2023-03-07T21:29:36.950143827Z” level=debug msg=“sql query executed” args=“[]” duration=1.352066ms query=“\n\t\tselect\n\t\t\tg.\n\t\tfrom gateway g\n\t\tinner join network_server ns\n\t\t\ton ns.id = g.network_server_id\n\t\twhere\n\t\t\tns.gateway_discovery_enabled = true\n\t\t\tand g.ping = true\n\t\t\tand (g.last_ping_sent_at is null or g.last_ping_sent_at <= (now() - (interval ‘24 hours’ / ns.gateway_discovery_interval)))\n\t\torder by last_ping_sent_at\n\t\tlimit 1\n\t\tfor update"
time=“2023-03-07T21:29:37.952878498Z” level=debug msg=“sql query executed” args=“[]” duration=1.216004ms query="\n\t\tselect\n\t\t\tg.
\n\t\tfrom gateway g\n\t\tinner join network_server ns\n\t\t\ton ns.id = g.network_server_id\n\t\twhere\n\t\t\tns.gateway_discovery_enabled = true\n\t\t\tand g.ping = true\n\t\t\tand (g.last_ping_sent_at is null or g.last_ping_sent_at <= (now() - (interval ‘24 hours’ / ns.gateway_discovery_interval)))\n\t\torder by last_ping_sent_at\n\t\tlimit 1\n\t\tfor update”
time=“2023-03-07T21:29:38.955591032Z” level=debug msg=“sql query executed” args=“[]” duration=1.176234ms query=“\n\t\tselect\n\t\t\tg.\n\t\tfrom gateway g\n\t\tinner join network_server ns\n\t\t\ton ns.id = g.network_server_id\n\t\twhere\n\t\t\tns.gateway_discovery_enabled = true\n\t\t\tand g.ping = true\n\t\t\tand (g.last_ping_sent_at is null or g.last_ping_sent_at <= (now() - (interval ‘24 hours’ / ns.gateway_discovery_interval)))\n\t\torder by last_ping_sent_at\n\t\tlimit 1\n\t\tfor update"
time=“2023-03-07T21:29:39.958879543Z” level=debug msg=“sql query executed” args=“[]” duration=1.215971ms query="\n\t\tselect\n\t\t\tg.
\n\t\tfrom gateway g\n\t\tinner join network_server ns\n\t\t\ton ns.id = g.network_server_id\n\t\twhere\n\t\t\tns.gateway_discovery_enabled = true\n\t\t\tand g.ping = true\n\t\t\tand (g.last_ping_sent_at is null or g.last_ping_sent_at <= (now() - (interval ‘24 hours’ / ns.gateway_discovery_interval)))\n\t\torder by last_ping_sent_at\n\t\tlimit 1\n\t\tfor update”
time=“2023-03-07T21:29:40.961720868Z” level=debug msg=“sql query executed” args=“[]” duration=1.084926ms query=“\n\t\tselect\n\t\t\tg.\n\t\tfrom gateway g\n\t\tinner join network_server ns\n\t\t\ton ns.id = g.network_server_id\n\t\twhere\n\t\t\tns.gateway_discovery_enabled = true\n\t\t\tand g.ping = true\n\t\t\tand (g.last_ping_sent_at is null or g.last_ping_sent_at <= (now() - (interval ‘24 hours’ / ns.gateway_discovery_interval)))\n\t\torder by last_ping_sent_at\n\t\tlimit 1\n\t\tfor update"
time=“2023-03-07T21:29:41.965304683Z” level=debug msg=“sql query executed” args=“[]” duration=1.216952ms query="\n\t\tselect\n\t\t\tg.
\n\t\tfrom gateway g\n\t\tinner join network_server ns\n\t\t\ton ns.id = g.network_server_id\n\t\twhere\n\t\t\tns.gateway_discovery_enabled = true\n\t\t\tand g.ping = true\n\t\t\tand (g.last_ping_sent_at is null or g.last_ping_sent_at <= (now() - (interval ‘24 hours’ / ns.gateway_discovery_interval)))\n\t\torder by last_ping_sent_at\n\t\tlimit 1\n\t\tfor update”
time=“2023-03-07T21:29:42.968134869Z” level=debug msg=“sql query executed” args=“[]” duration=1.173081ms query=“\n\t\tselect\n\t\t\tg.\n\t\tfrom gateway g\n\t\tinner join network_server ns\n\t\t\ton ns.id = g.network_server_id\n\t\twhere\n\t\t\tns.gateway_discovery_enabled = true\n\t\t\tand g.ping = true\n\t\t\tand (g.last_ping_sent_at is null or g.last_ping_sent_at <= (now() - (interval ‘24 hours’ / ns.gateway_discovery_interval)))\n\t\torder by last_ping_sent_at\n\t\tlimit 1\n\t\tfor update"
time=“2023-03-07T21:29:43.972039804Z” level=debug msg=“sql query executed” args=“[]” duration=1.705817ms query="\n\t\tselect\n\t\t\tg.
\n\t\tfrom gateway g\n\t\tinner join network_server ns\n\t\t\ton ns.id = g.network_server_id\n\t\twhere\n\t\t\tns.gateway_discovery_enabled = true\n\t\t\tand g.ping = true\n\t\t\tand (g.last_ping_sent_at is null or g.last_ping_sent_at <= (now() - (interval ‘24 hours’ / ns.gateway_discovery_interval)))\n\t\torder by last_ping_sent_at\n\t\tlimit 1\n\t\tfor update”
time=“2023-03-07T21:29:44.975613503Z” level=debug msg=“sql query executed” args=“[]” duration=1.288405ms query=“\n\t\tselect\n\t\t\tg.\n\t\tfrom gateway g\n\t\tinner join network_server ns\n\t\t\ton ns.id = g.network_server_id\n\t\twhere\n\t\t\tns.gateway_discovery_enabled = true\n\t\t\tand g.ping = true\n\t\t\tand (g.last_ping_sent_at is null or g.last_ping_sent_at <= (now() - (interval ‘24 hours’ / ns.gateway_discovery_interval)))\n\t\torder by last_ping_sent_at\n\t\tlimit 1\n\t\tfor update"
time=“2023-03-07T21:29:45.980018082Z” level=debug msg=“sql query executed” args=“[]” duration=1.240677ms query="\n\t\tselect\n\t\t\tg.
\n\t\tfrom gateway g\n\t\tinner join network_server ns\n\t\t\ton ns.id = g.network_server_id\n\t\twhere\n\t\t\tns.gateway_discovery_enabled = true\n\t\t\tand g.ping = true\n\t\t\tand (g.last_ping_sent_at is null or g.last_ping_sent_at <= (now() - (interval ‘24 hours’ / ns.gateway_discovery_interval)))\n\t\torder by last_ping_sent_at\n\t\tlimit 1\n\t\tfor update”

I do not see any errors, only level=debug messages…

Sorry for delay in reply.
It was a strange issue. Someone in the team deleted some devices and device profile in the application server, but those were still present in the network server DB table for devices, device profiles, and device queues and were not cleaned .

I had to manually clean those from the network server DB, and it solved the problem.