elllusion / androboinc

Automatically exported from code.google.com/p/androboinc
0 stars 0 forks source link

Connection to remote client breaks after a very short time #21

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

 1. Use AndroBOINC to connect BOINC client running at Ubuntu 12.04 LTS

What is the expected output? What do you see instead?

 - Expected is that the connection to the client is kept established
 - The Connection breaks after a very short time with the AndroBOINC
   dialog box.

What version of the product are you using?

 1. AndroBOINC version: v6.10.58.rc3
 2. BOINC client version: v7.0.27 (Ubuntu 12.04 LTS)

What is the vendor/model of the device? What is the Android version?

 - Tested with HTC Desire HD on Android 2.3.5 (not rooted)
 - Tested with Samsung GalaxyTab 10.1N on Android 3.2 (not rooted)

Please provide any additional information below.

 - Remote controlling the client via Win Vista BOINC-Manager
   is working fine.
 - Attached gui_rpc debug information (see file stdoutdae.txt)

Original issue reported on code.google.com by DaniloAd...@gmail.com on 4 Oct 2012 at 8:02

Attachments:

GoogleCodeExporter commented 8 years ago
The same behavior appears when i try to connect my windows boinc-client. 
Connecting with the boinc manager from localhost or a remote host to the 
windows client works fine.

 - BOINC client version: v7.0.28 (WinVista SP2)
 - Attached gui_rpc debug information from windows client
   (see file stdoutdae-windows.txt)

Greets, Danilo

Original comment by DaniloAd...@gmail.com on 4 Oct 2012 at 9:41

Attachments:

GoogleCodeExporter commented 8 years ago
Thank you for reporting the useful technical details about this issue. 

It seems the problem is caused by gui_rpc logging itself 
(<gui_rpc_debug>1</gui_rpc_debug> flag in cc_config.xml), at least I was able 
to reproduce the problem this way.
The root cause is, that the body of message contains unescaped xml tags in case 
of gui_rpc logging and since the content of GUI-RPC data is truncated (due to 
its length), some tags are not closed properly and there is XML-decoding error 
in AndroBOINC. 

Example of such raw data in network socket is:
<msgs>
<msg>
 <project></project>
 <pri>1</pri>
 <seqno>178</seqno>
 <body>[gui_rpc] GUI RPC reply: '<boinc_gui_rpc_reply>
<server_version>
<major>7</major>
<minor>0</minor>
<release>28</release>
</server_version>
</boin'
 </body>
</msg>
</msgs>

In the example above, the body of message: (part between <body> and </body>) is 
violating the XML rules (according to XML decoder the opening tag 
"<boinc_gui_rpc_reply>" is not properly closed, because it is truncated as 
"</boin" and also, there is a text together with inner tag inside the tag). If 
that should be correct XML, the body of message should be properly escaped for 
XML (i.e. the "<" should be replaced by "<" and ">" should be replaced by ">", 
so they would not be considered as XML tags, but just pure text - and the 
correct characters could be shown as resulting message text as well). 

Please note that AndroBOINC uses SAX library to parse XMLs which also checks 
for correctness of structure (i.e. all tags must be properly closed), while 
BOINC client/manager uses its own code to encode/decode XML and the correctness 
of XML is not enforced in BOINC. 

So, the root cause of this problem lies inside BOINC itself. The BOINC manager 
does not mind that BOINC client sends the incorrect XML, because the BOINC 
manager uses the similar code as client does (it does not care about 
XML-compliant structure). 
Please note also that it will be very difficult to solve this in AndroBOINC: 
Making the code similarily wrong as it is in BOINC itself is really bad idea; 
It would significantly increase code size and complexity and possibly introduce 
new bugs and it would also slow down the execution (while on PC it does not 
matter, on mobile phones the speed difference would be significant). Better way 
would be to convince BOINC responsibles to make proper XML encoding in client 
but let's be realistic about it (we cannot really expect the solution there any 
time soon and old clients are out in the world already anyway).

I will try to find a workaround in AndroBOINC for received broken XML, but it 
will always be trade-off for performance (so please also consider whether the 
extensive log-flags like gui_rpc_debug are really needed for regular usage in 
your clients - besides this issue the extensive logging also increases data 
usage of your mobile connection).

Meanwhile, please try to turn off (at least temporarily) all log-flags in 
cc_config.xml which could insert unescaped XML-tags into body of message 
(gui_rpc_debug and unparsed_xml are surely candidates, but there could be more 
tags violating the XML), then restart BOINC client and observe behaviour of 
AndroBOINC. Please report if the problem disappears when these extra logging 
flags are turned off, so we can confirm that your issue is also caused by the 
XML.

Original comment by pavol.michalec@gmail.com on 4 Oct 2012 at 2:47

GoogleCodeExporter commented 8 years ago
I've deactivated all logging-flags but unfortunatly the problem still appears. 
Instead of using the BOINC log messages i did a tcp dump of the connections. 
(The files will be mailed to you)

 - androBOINC2.tcpdump ... net traffic of androBOINC and my Unbuntu BOINC client
 - androBOINC3.tcpdump ... net traffic of BOINC Manager and my Ubuntu BOINC-client

It seems that the BOINC messages arrives androBOINC in a correct manner. After 
that the connection is just closed?

Hope it helps.

Original comment by DaniloAd...@gmail.com on 5 Oct 2012 at 10:03

GoogleCodeExporter commented 8 years ago
The tcpdump shows following suspicious message:
<msg>
 <project></project>
 <pri>2</pri>
 <seqno>18</seqno>
 <body>
A new version of BOINC is available. <a 
href=http://boinc.berkeley.edu/download.php>Download it.</a>
</body>
 <time>1349374272</time>
</msg>
Unfortunately I cannot reproduce this myself, my clients do not emit such 
message (I have versions 6.10.17, 6.10.58 and 7.0.28 running). I cannot run 
precompiled BOINC package from boinc.berkeley.edu on my hosts due to dynamic 
libraries incompatibility - I compile my own binary from source and it is not 
guaranteed the behaviour will be the same as official one (due to different 
versions of libraries). So I am not sure I will be able to reproduce this if I 
compile BOINC client 7.0.27 (I will try but it will take me some time).

It seems this notice appears only shortly after start of BOINC client. So 
following procedure could be used to verify if this message is causing the 
trouble:
1. Make sure that AndroBOINC preference "Limit number of messages" is enabled 
(it should be the case according to tcpdump)
2. After starting of BOINC client, make sure there are more than 50 messages 
after the "A new version of BOINC is available" message by using BOINC manager 
(e.g. by suspending network communication, setting no-new work for some project 
and enabling new work again, or so).
3. Then, when there are enough of dummy messages in BOINC log, try to connect 
via AndroBOINC. If it is not disconnected when message "A new version of BOINC 
is available" is invisible (older than recent 50 messages), then we can confirm 
the suspicion.

Also, according to http://boinc.berkeley.edu/download_all.php the 7.0.28 is 
currently the recommended version for both Windows and Linux. So the message "A 
new version of BOINC is available" should occur only on your Ubuntu host 
(running BOINC 7.0.27), but it should not occur on Windows Vista host (which is 
running BOINC 7.0.28) - so if the logging flags are disabled in both Windows 
and Linux host (and message "A new version of BOINC is available" is not 
present on Windows host) and the AndroBOINC does not disconnect from Windows 
host (but disconnects from Linux host), then it can be also confirmed that this 
message causes troubles.

Original comment by pavol.michalec@gmail.com on 5 Oct 2012 at 2:25

GoogleCodeExporter commented 8 years ago
I was finally able to reproduce the problem.
The suspected message is really causing it, the immediate reason seems to be 
that href value is not enclosed in quotes, therefore it is not valid XML. 
Unfortunately, XML-parser has draconian policy (i.e. it ceases the processing 
when XML formatting error is encountered) by definition.

However, the message about new version seems to be emited only in case that 
BOINC client is started by BOINC manager, but the message does not appear when 
BOINC client is started standalone (Wiki of AndroBOINC describes standalone 
starting of BOINC client and this is the way I am using it myself). So the 
standalone starting of BOINC (by shell script on Linux or by batch-file on 
Windows) could be used as another temporary workaround until the AndroBOINC 
correction is deployed.

Original comment by pavol.michalec@gmail.com on 6 Oct 2012 at 7:49

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r78.

Original comment by pavol.michalec@gmail.com on 6 Oct 2012 at 2:19

GoogleCodeExporter commented 8 years ago
Confirm the workaround by turning off the looging-flags and avoiding the "new 
client version" message on androBOINC 6.10.58.rc3 works very well.

Can also confirm the fix in 6.10.58.rc4 so the "new client version" message and 
turned on logging-flags causes no disconnections anymore.

Great Job. Thx.

Original comment by DaniloAd...@gmail.com on 7 Oct 2012 at 11:56

GoogleCodeExporter commented 8 years ago

Original comment by pavol.michalec@gmail.com on 7 Oct 2012 at 3:01