Project

General

Profile

[Solved] webserver with multiple IP addresses "call itself" and hang....

Added by lhl over 4 years ago

Hello
Please excuse this long text but it is a complex problem.

I experience that fopen($url) and stream_get_contents() is hanging. And I need help to narrow down the problem
I suspect it to be some kind of resource depletion / timeout / semaphore - when a web-server calls itself.

But I need an indication where to look. Any kind of help is appreciated.

It has been working flawlessly with a previous version (lighttpd 1.4.19)

It is an embedded system with multiple computers with static IP addresses, all computers have a web-server.
One of them is the designated "master web-server"

Say the IP net is "192.168.2.255" - the master web-server is always found at IP_net.199 ( that is 192.168.2.199)
each computer (all slaves AND the master) is expected to have a web-server at .10n (in this case 192.168.1.101)

So the Master web-server service two IP addresses (.199 and .101)
the external world (web browsers) always talk to the Master at .199.
main functionality is to concatenate a number of json files from all "slave URLs" (including its own .101 address)

So the web-server "calls" it self. It works well for 1 or 2 iterations - then something looks up and I get loong hangs.

Kind regards Lars

in a web-browser pointed at http://192.168.2.199
pseudo java script
while (true) {
ajax(GET, http:192.168.2.199/get_allvalues.php);
wait( 0.5 second)
}

get_allvalues.php: (real code attached ) but here is the loop, in pseudo code


    for ($i= 1; $i <max;$i++)
    {
    $handler = @fopen('http://192.168.2.10' . $i . '/progdir/parms.json','r') ;
      if ($handler != FALSE) {
      $a =stream_get_meta_data($handler);
      $filecont =$filecont. stream_get_contents($handler,$a["unread_bytes"]) ;
      fclose($handler) ;
      $a=0; }
    $handler = @fopen('http://192.168.2.10' . $i . '/progdir/errorstate.json','r') ;
      if ($handler != FALSE) {
      $a =stream_get_meta_data($handler);
      $filecont =$filecont.stream_get_contents($handler,$a["unread_bytes"]) ;
      fclose($handler) ;
      $a=0; }
    $handler = @fopen('http://192.168.2.10' . $i . '/progdir/errorstate.json','r') ;
      if ($handler != FALSE) {
      $a =stream_get_meta_data($handler);
      $filecont =$filecont.stream_get_contents($handler,$a["unread_bytes"]) ;
      fclose($handler) ;
      $a=0; }
    }
  print ($filecont)

misc. version details

#uname -a
Linux Computer-2-MASTER 4.1.17-yocto-standard #1 SMP PREEMPT Thu Nov 3 09:45:23 CET 2016 i686 GNU/Linux

#lighttpd -v
lighttpd/1.4.36 (ssl) - a light and fast webserver
Build-Date: Nov 23 2016 10:44:12

  1. php-cgi -v
    PHP 5.6.25 (cgi-fcgi) (built: Nov 10 2016 13:44:39)
    Copyright (c) 1997-2016 The PHP Group

#ifconfig
eth0 Link encap:Ethernet HWaddr 08:00:27:1E:70:01
inet addr:192.168.2.12 Bcast:192.168.2.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe1e:7001/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:13647 errors:0 dropped:92 overruns:0 frame:0
TX packets:46945 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1361632 (1.2 MiB) TX bytes:6937764 (6.6 MiB)

eth0:0 Link encap:Ethernet HWaddr 08:00:27:1E:70:01
inet addr:192.168.2.101 Bcast:192.168.2.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

eth0:1 Link encap:Ethernet HWaddr 08:00:27:1E:70:01
inet addr:192.168.2.199 Bcast:192.168.2.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

eth0:2 Link encap:Ethernet HWaddr 08:00:27:1E:70:01
inet addr:192.168.2.211 Bcast:192.168.2.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1


Replies (2)

RE: webserver with multiple IP addresses "call itself" and hang.... - Added by gstrauss over 4 years ago

#lighttpd -v
lighttpd/1.4.36 (ssl) - a light and fast webserver
Build-Date: Nov 23 2016 10:44:12

Since it appears that you are buiding lighttpd yourself, would you please test with the latest version? lighttpd 1.4.43 is latest, and lighttpd git master (a few revisions ahead of 1.4.43) can be found at DevelGit: git clone https://git.lighttpd.net/lighttpd/lighttpd1.4.git

You might want to test disabling mod_compress to remove that factor.

RE: webserver with multiple IP addresses "call itself" and hang.... - Added by lhl over 4 years ago

Hi Glenn

Thanks for taking some time with me on this issue.

As you noticed, I do build myself as part of an openembedded (OE) Yocto/Poky build.
I used the "jehtro" version of OE that provides the 1.4.36 version of lighttpd
the latest version of OE/Yocto is "morty" that uses lighttpd in version 1.4.41

As I need to stay with the Yocto path for my base system, I tried with version lighttpd v 1.4.41 and it removes my problem.

So something in v.1.4.36 is not good.
And I will bump my yocto checkout to "morty".

Regards Lars

    (1-2/2)