Kiougar / luci-wrtbwmon

Bandwidth tracker for OpenWRT that uses wrtbwmon
https://github.com/pyrovski/wrtbwmon
MIT License
319 stars 56 forks source link

OpenWrt error information #4

Closed angusding closed 7 years ago

angusding commented 7 years ago

I setup wrtbwmon and luci-wrtbwmon in OpenWrt Chaos Calmer and Barrier Breaker. But all of them can't display "Network Usage:". It display the same error in the Chrome and Opera browser.

This page contains the following errors:
error on line 156 at column 43: Specification mandate value for attribute selected
Below is a rendering of the page up to the first error.

That's the contents of the file /tmp/usage.db:

#mac,ip,iface,in,out,total,first_date,last_date
bc:e6:3f:61:be:5e,192.168.0.217,br-lan,3291879,689018,3980897,22-02-2017_22:41:18,22-02-2017_23:06:21
22:76:93:28:0e:44,192.168.0.251,br-lan,0,0,0,22-02-2017_22:41:18,22-02-2017_22:41:18
00:e1:4d:71:00:ba,192.168.0.254,br-lan,0,0,0,22-02-2017_22:41:18,22-02-2017_22:41:18
ba:ee:e3:bc:0d:b3,192.168.0.9,br-lan,0,0,0,22-02-2017_22:41:18,22-02-2017_22:41:18
00:c2:c6:9f:7a:0e,192.168.0.10,br-lan,0,0,0,22-02-2017_22:41:18,22-02-2017_22:41:18
98:83:89:29:01:4a,192.168.0.11,br-lan,171663132,170769018,342432150,22-02-2017_22:41:18,22-02-2017_23:06:21
00:c2:c6:9f:7a:0e,192.168.0.21,br-lan,0,0,0,22-02-2017_22:41:18,22-02-2017_22:41:18
b0:e2:35:07:c8:b6,192.168.0.121,br-lan,522662,43745,566407,22-02-2017_22:41:18,22-02-2017_23:06:21
Kiougar commented 7 years ago

What versions of Chrome/Opera are you using?

I have a "solution" in mind but I want you to test it first to see if that's the actual problem. Are you familiar with the vi command line editor?

angusding commented 7 years ago

Chrome version: 55.0.2883.87 (64-bit) Opera version: 43.0.2442.806 (PGO) I can use vim and edit what your solution need.

Kiougar commented 7 years ago

@angusding OK, try editing the file /usr/lib/lua/luci/view/wrtbwmon.htm. Change the line 10 from:

<option value="5" selected>5 seconds</option>

to

<option value="5" selected="selected">5 seconds</option>

And then try to load the page. Let me know if the error disappears.

angusding commented 7 years ago

The new error information as follows:

This page contains the following errors:
error on line 216 at column 32: StartTag: invalid element name
Below is a rendering of the page up to the first error.

The page "usage" display new information: "Loading..." and "Auto update every" option.

Kiougar commented 7 years ago

Seems like the browser tries to display the page as an XML file. Can you provide a screenshot of what you see when you try to load the page with developer tools open? I want to take a look on the request and response headers.

Kiougar commented 7 years ago

Also, can you please paste here the contents of the /etc/config/uhttpd file?

angusding commented 7 years ago

root@WNDR3700v4:/tmp# cat /etc/config/uhttpd

config uhttpd 'main'
    list listen_http '0.0.0.0:80'
    list listen_http '[::]:80'
    list listen_https '0.0.0.0:443'
    list listen_https '[::]:443'
    option home '/www'
    option rfc1918_filter '1'
    option max_requests '3'
    option max_connections '100'
    option cert '/etc/uhttpd.crt'
    option key '/etc/uhttpd.key'
    option cgi_prefix '/cgi-bin'
    option script_timeout '60'
    option network_timeout '30'
    option http_keepalive '20'
    option tcp_keepalive '1'
    option ubus_prefix '/ubus'

config cert 'px5g'
    option days '730'
    option bits '1024'
    option country 'DE'
    option state 'Berlin'
    option location 'Berlin'
    option commonname 'OpenWrt'
angusding commented 7 years ago
root@OpenWrt:~# cat /etc/config/uhttpd 

config uhttpd 'main'
    list listen_http '0.0.0.0:80'
    list listen_http '[::]:80'
    list listen_https '0.0.0.0:443'
    list listen_https '[::]:443'
    option redirect_https '0'
    option home '/www'
    option rfc1918_filter '1'
    option max_requests '3'
    option max_connections '100'
    option cert '/etc/uhttpd.crt'
    option key '/etc/uhttpd.key'
    option cgi_prefix '/cgi-bin'
    option script_timeout '60'
    option network_timeout '30'
    option http_keepalive '20'
    option tcp_keepalive '1'
    option ubus_prefix '/ubus'

config cert 'px5g'
    option days '730'
    option bits '1024'
    option country 'ZZ'
    option state 'Somewhere'
    option location 'Uknown'
    option commonname 'OpenWrt'
angusding commented 7 years ago

That's the configuration of BB and CC. They have the same error information.

Kiougar commented 7 years ago

Thanks, can you also provide the Response and Request Headers from the developer tools?

This is how to get them on Chrome:

angusding commented 7 years ago

That's you want?

GET /cgi-bin/luci/;stok=fdd36e3a0fca084101b95734636a78dd/admin/network/usage/ HTTP/1.1
Host: 192.168.0.1
Connection: keep-alive
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Referer: http://192.168.0.1/cgi-bin/luci/;stok=fdd36e3a0fca084101b95734636a78dd/admin/network/usage/
Accept-Encoding: gzip, deflate, sdch
Accept-Language: zh-CN,zh;q=0.8
Cookie: sysauth=b45c5aa7e24774a88647b14708a19947
Kiougar commented 7 years ago

Yes, and the response headers please.

angusding commented 7 years ago
HTTP/1.1 200 OK
Connection: Keep-Alive
Transfer-Encoding: chunked
Keep-Alive: timeout=20
Vary: Accept
Content-Type: application/xhtml+xml
Cache-Control: no-cache
Expires: 0
Kiougar commented 7 years ago

OK. Can you please try one more edit on the same /usr/lib/lua/luci/view/wrtbwmon.htm file on line 148:

from:

'<td title="' + data[1] + '">' + data[0] + '<br>' + data[2] + '</td>',

to

'<td title="' + data[1] + '">' + data[0] + '<br />' + data[2] + '</td>',

Let me know how it goes.

angusding commented 7 years ago

That's OK. The new error information:

This page contains the following errors:
error on line 216 at column 32: StartTag: invalid element name
Below is a rendering of the page up to the first error.

As if nothing changed. request headers:

GET /cgi-bin/luci/;stok=ff4c8646e2fabfaea37b69954c24c14e/admin/network/usage/ HTTP/1.1
Host: 192.168.0.1
Connection: keep-alive
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Referer: http://192.168.0.1/cgi-bin/luci/;stok=ff4c8646e2fabfaea37b69954c24c14e/admin/network/usage/
Accept-Encoding: gzip, deflate, sdch
Accept-Language: zh-CN,zh;q=0.8
Cookie: sysauth=54315d67aae38b593f3222f5253353bd

response headers:

HTTP/1.1 200 OK
Connection: Keep-Alive
Transfer-Encoding: chunked
Keep-Alive: timeout=20
Vary: Accept
Content-Type: application/xhtml+xml
Cache-Control: no-cache
Expires: 0
Kiougar commented 7 years ago

OK, I think I found the issue.

One more edit and it should fix the problem. Please, add this line

//<![CDATA[

below the <script> tag in line 28. And this line

//]]>

before the </script> tag in line 241.

angusding commented 7 years ago

Yes. The error message disappears. Just keep loading ...

GET /cgi-bin/luci/;stok=ff4c8646e2fabfaea37b69954c24c14e/admin/network/usage/ HTTP/1.1
Host: 192.168.0.1
Connection: keep-alive
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Referer: http://192.168.0.1/cgi-bin/luci/;stok=ff4c8646e2fabfaea37b69954c24c14e/admin/network/usage/
Accept-Encoding: gzip, deflate, sdch
Accept-Language: zh-CN,zh;q=0.8
Cookie: sysauth=54315d67aae38b593f3222f5253353bd
HTTP/1.1 200 OK
Connection: Keep-Alive
Transfer-Encoding: chunked
Keep-Alive: timeout=20
Vary: Accept
Content-Type: application/xhtml+xml
Cache-Control: no-cache
Expires: 0
Kiougar commented 7 years ago

So nothing happens?

Can you open the developer tools again, click the Console tag and take a screenshot after you refresh?

angusding commented 7 years ago

Console message: http://192.168.0.1/cgi-bin/luci/;stok=1bea057eca64e8098809446aaba7ea9f/admin/network/usage/usage_data 404 (Not Found)

Kiougar commented 7 years ago

Thanks a lot @angusding for the effort!

I have all I need now to create a new version with the fixes.

This issue will be closed when the new version is uploaded.