Well, I have the reply from the device that I’m trying to add.
In the image bellow you can see that the server replies for the ping from addhost and after that it replies for a snmpwalk that asked for sysDescr.
The script addhost.php stops after the ping, but the web version, addhost.inc.php works fine, what this script does different? This problem happens with any device, this is not a firewall problem, the servers in the example above do not have a firewall between them.
I did a strace of the addhost.php and I can see that it calls HostUnreachableException.php after the ping results.
fstat(5, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
fcntl(5, F_SETFD, FD_CLOEXEC) = 0
close(7) = 0
fstat(6, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
fcntl(6, F_SETFD, FD_CLOEXEC) = 0
close(9) = 0
fstat(8, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
fcntl(8, F_SETFD, FD_CLOEXEC) = 0
close(5) = 0
read(6, "az-kb001 : xmt/rcv/%loss = 3/3/0"..., 8192) = 64
read(6, "", 8192) = 0
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=6311, si_uid=1001, si_status=0, si_utime=0, si_stime=0} ---
close(6) = 0
wait4(6311, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], WNOHANG|WSTOPPED, NULL) = 6311
close(8) = 0
wait4(6311, 0x7ffd5c422694, 0, NULL) = -1 ECHILD (No child processes)
access("/opt/librenms/vendor/composer/../../LibreNMS/Exceptions/HostUnreachableException.php", F_OK) = 0
lstat("/opt/librenms/vendor/composer/../../LibreNMS/Exceptions/HostUnreachableException.php", {st_mode=S_IFREG|0664, st_size=1509, ...}) = 0
lstat("/opt/librenms/vendor/composer/../../LibreNMS/Exceptions", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
open("/opt/librenms/LibreNMS/Exceptions/HostUnreachableException.php", O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0664, st_size=1509, ...}) = 0
fstat(4, {st_mode=S_IFREG|0664, st_size=1509, ...}) = 0
fstat(4, {st_mode=S_IFREG|0664, st_size=1509, ...}) = 0
mmap(NULL, 1509, PROT_READ, MAP_SHARED, 4, 0) = 0x7fc713269000
munmap(0x7fc713269000, 1509) = 0
close(4) = 0
write(1, "\33[0;31mCould not connect to az-k"..., 94) = 94
close(2) = 0
close(1) = 0
close(0) = 0
munmap(0x7fc6fd800000, 2097152) = 0
write(3, "\1\0\0\0\1", 5) = 5
shutdown(3, SHUT_RDWR) = 0
close(3) = 0