Stats over Unix or TCP socket

Expected Behaviour:

connecting to Unix socket, I should receive something similar to:

{"domains_being_blocked":99867,"dns_queries_today":2275,"ads_blocked_today":422,"ads_percentage_today":18.549450}

Actual Behaviour:

Socket read hangs

I looked through the AdminLTE code on Github, and see how a socket connection is made in PHP, I created a very simple PHP script to test:

<?php
  $address = '127.0.0.1';
  $port = 4711;
  $socket = @fsockopen($address, $port);
  $out = fgets($socket);
  $out = rtrim($out);
  print_r($out);
  fclose($socket);
?>

also tried in Ruby:

require "socket"
socket = UNIXSocket.new('/run/pihole/FTL.sock')
puts "--- Read from Socket ---"
puts socket.read(10)
socket.close

Both running locally, both result in a hung execution, no exception thrown. I'm at a loss here, hoping someone has some ideas or knowledge around Pi-hole stats over Unix or TCP socket.

Debug Token:

https://tricorder.pi-hole.net/go05a0dqib

May have found the missing issue, I needed to send a message to the socket before getting a response. Over TCP I was able to send the string ">stats" which did return wha I was expecting. Still nothing over Unix socket though.

Just a heads up, version 6 is planned to have a new API and the telnet interface will be going away.

Thanks for the heads DanSchaper. Version 6 will retain the Unix socket? How will the AdminLTE service retrieve stats?

The plan is for pihole-FTL to be have a full REST API.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.