mbolli / nfsen-ng

Responsive NetFlow visualizer built on top of nfdump tools.
Apache License 2.0
231 stars 43 forks source link

reload loop #102

Closed WimRooseUG closed 7 months ago

WimRooseUG commented 7 months ago

After update to v0.3 this week, nfsen-ng is broken, as site goes into an endless reload loop. Tried on a fresh debian 12 vagrant vm, with new install instructions, same result.

Loop seems to be introduced by upgrade of bootstrap https://github.com/mbolli/nfsen-ng/commit/a1428de78089e2367b0573f4a416cc2477db5c8e

mbolli commented 7 months ago

Can you post the 301 request which is looping? Or what kind of loop is it?

WimRooseUG commented 7 months ago

After javascript libs are fetched, site starts to reload endlessly

10.0.2.2 - - [06/Mar/2024:10:56:38 +0000] "GET / HTTP/1.1" 301 580 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"
10.0.2.2 - - [06/Mar/2024:10:56:38 +0000] "GET /frontend/ HTTP/1.1" 200 5899 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"
10.0.2.2 - - [06/Mar/2024:10:56:38 +0000] "GET /frontend/js/jquery.min.js HTTP/1.1" 200 89832 "http://localhost:8080/frontend/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"
10.0.2.2 - - [06/Mar/2024:10:56:38 +0000] "GET /frontend/js/popper.min.js HTTP/1.1" 200 20462 "http://localhost:8080/frontend/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"
10.0.2.2 - - [06/Mar/2024:10:56:38 +0000] "GET /frontend/css/dygraph.css HTTP/1.1" 200 1304 "http://localhost:8080/frontend/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"
10.0.2.2 - - [06/Mar/2024:10:56:38 +0000] "GET /frontend/css/footable.bootstrap.min.css HTTP/1.1" 200 2013 "http://localhost:8080/frontend/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"
10.0.2.2 - - [06/Mar/2024:10:56:38 +0000] "GET /frontend/css/ion.rangeSlider.css HTTP/1.1" 200 1599 "http://localhost:8080/frontend/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"
10.0.2.2 - - [06/Mar/2024:10:56:38 +0000] "GET /frontend/js/bootstrap.min.js HTTP/1.1" 200 60917 "http://localhost:8080/frontend/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"
10.0.2.2 - - [06/Mar/2024:10:56:38 +0000] "GET /frontend/js/ion.rangeSlider.min.js HTTP/1.1" 200 41868 "http://localhost:8080/frontend/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"
10.0.2.2 - - [06/Mar/2024:10:56:38 +0000] "GET /frontend/css/bootstrap.min.css HTTP/1.1" 200 31687 "http://localhost:8080/frontend/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"
10.0.2.2 - - [06/Mar/2024:10:56:38 +0000] "GET /frontend/js/dygraph.min.js HTTP/1.1" 200 131392 "http://localhost:8080/frontend/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"
10.0.2.2 - - [06/Mar/2024:10:56:38 +0000] "GET /frontend/js/nfsen-ng.js HTTP/1.1" 200 53990 "http://localhost:8080/frontend/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"
10.0.2.2 - - [06/Mar/2024:10:56:38 +0000] "GET /frontend/css/nfsen-ng.css HTTP/1.1" 200 1145 "http://localhost:8080/frontend/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"
10.0.2.2 - - [06/Mar/2024:10:56:38 +0000] "GET /frontend/js/footable.min.js HTTP/1.1" 200 82763 "http://localhost:8080/frontend/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"
10.0.2.2 - - [06/Mar/2024:10:56:39 +0000] "GET /favicon.ico HTTP/1.1" 404 412 "http://localhost:8080/frontend/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"
10.0.2.2 - - [06/Mar/2024:10:56:39 +0000] "GET /api/config HTTP/1.1" 200 522 "http://localhost:8080/frontend/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"
10.0.2.2 - - [06/Mar/2024:10:56:39 +0000] "GET /frontend/css/sprite-skin-nice.png HTTP/1.1" 200 1081 "http://localhost:8080/frontend/css/ion.rangeSlider.css" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"
10.0.2.2 - - [06/Mar/2024:10:56:39 +0000] "GET /frontend/ HTTP/1.1" 200 5899 "http://localhost:8080/frontend/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"
10.0.2.2 - - [06/Mar/2024:10:56:39 +0000] "GET /api/config HTTP/1.1" 200 522 "http://localhost:8080/frontend/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"
10.0.2.2 - - [06/Mar/2024:10:56:39 +0000] "GET /frontend/ HTTP/1.1" 200 5899 "http://localhost:8080/frontend/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"
10.0.2.2 - - [06/Mar/2024:10:56:39 +0000] "GET /api/config HTTP/1.1" 200 522 "http://localhost:8080/frontend/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"
10.0.2.2 - - [06/Mar/2024:10:56:39 +0000] "GET /frontend/ HTTP/1.1" 200 5899 "http://localhost:8080/frontend/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"
10.0.2.2 - - [06/Mar/2024:10:56:39 +0000] "GET /api/config HTTP/1.1" 200 522 "http://localhost:8080/frontend/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"
mbolli commented 7 months ago

Can you find out the initiator of the request using the Chrome DevTools?

image

I don't have this problem on any of my machines, but it is weird that you are getting it on a fresh system.

WimRooseUG commented 7 months ago

image

Weird, so https://github.com/mbolli/nfsen-ng/blob/master/frontend/js/nfsen-ng.js#L160 is triggering the reload

mbolli commented 7 months ago

is it the same if you activate the checkbox "Disable cache" on the second menu row?

WimRooseUG commented 7 months ago

Yes, makes no difference

mbolli commented 7 months ago

So if you remove that line the loop is fixed?

WimRooseUG commented 7 months ago

Yes, I can confirm that

mbolli commented 7 months ago

The line in question should only be executed when clicking the home button in the header. Can you open the dev tools and set a break point at line 159 (first line inside the click handler) to see in the call stack why it was called in the first place?

WimRooseUG commented 7 months ago
(anonymous) (nfsen-ng.js:159)
dispatch (jquery.min.js:2)
v.handle (jquery.min.js:2)
trigger (jquery.min.js:2)
(anonymous) (jquery.min.js:2)
each (jquery.min.js:2)
each (jquery.min.js:2)
trigger (jquery.min.js:2)
init (nfsen-ng.js:423)
(anonymous) (nfsen-ng.js:83)
c (jquery.min.js:2)
fireWith (jquery.min.js:2)
l (jquery.min.js:2)
(anonymous) (jquery.min.js:2)
load (async)
send (jquery.min.js:2)
ajax (jquery.min.js:2)
S.<computed> (jquery.min.js:2)
(anonymous) (nfsen-ng.js:80)
e (jquery.min.js:2)
t (jquery.min.js:2)
setTimeout (async)
(anonymous) (jquery.min.js:2)
c (jquery.min.js:2)
fireWith (jquery.min.js:2)
fire (jquery.min.js:2)
c (jquery.min.js:2)
fireWith (jquery.min.js:2)
ready (jquery.min.js:2)
B (jquery.min.js:2)

Let me know if you need additional debug info

mbolli commented 7 months ago

Ah now I see it, thanks.

Can you check the settings.php and compare with this:

https://github.com/mbolli/nfsen-ng/blob/5f7fb1ecd2f1b0d4d99d9e75d95bd614508dc649/backend/settings/settings.php.dist#L21-L36

Apparently, if the setting frontend.defaults.view is not set, it will emulate a click on the home button. I will fix that, but for you it's better anyway to have an up-to-date settings file.

WimRooseUG commented 7 months ago

Hmm, wondering why I've never implemented the frontend defaults in the settings.php. On our systems, that file is managed by a puppet template - maybe I just followed the docs when I created the template a couple of years ago.

Anyway, thanks for the help and the fix, @mbolli !