Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] - Google drive uploading is unstable #345

Open
xAt0mZ opened this issue Dec 8, 2020 · 2 comments
Open

[BUG] - Google drive uploading is unstable #345

xAt0mZ opened this issue Dec 8, 2020 · 2 comments

Comments

@xAt0mZ
Copy link

xAt0mZ commented Dec 8, 2020

Phone: Xperia XZ1 - Firmware build 47.2.A.11.228 (latest available)
Android: 9.0.0
OS version: Windows 10 1909
gnirehtet version: 2.5 (Rust)

When trying to achieve a Google Photo backup (from Phone to Google Drive), proxy is throwing errors on requests then crashing after some time.

2020-12-08 03:18:48.701 INFO TcpConnection: 10.0.0.2:42589 -> 216.58.201.234:443 Open                                                                                                                                                        2020-12-08 03:18:48.701 WARN TcpConnection: 10.0.0.2:42589 -> 216.58.201.234:443 Unexpected first packet 656137655; acking 4069385229; flags=16
2020-12-08 03:18:48.701 INFO TcpConnection: 10.0.0.2:42589 -> 216.58.201.234:443 Close                                                                                                                                                       2020-12-08 03:18:48.701 INFO TcpConnection: 10.0.0.2:42589 -> 216.58.201.234:443 Open                                                                                                                                                        2020-12-08 03:18:48.701 WARN TcpConnection: 10.0.0.2:42589 -> 216.58.201.234:443 Unexpected first packet 656138191; acking 4069385229; flags=16
2020-12-08 03:18:48.702 INFO TcpConnection: 10.0.0.2:42589 -> 216.58.201.234:443 Close                                                                                                                                                       2020-12-08 03:19:02.756 WARN UdpConnection: 10.0.0.2:47085 -> 216.58.201.234:443 Cannot send to network, drop packet: Datagram buffer is full
2020-12-08 03:19:02.756 WARN UdpConnection: 10.0.0.2:47085 -> 216.58.201.234:443 Cannot send to network, drop packet: 
...
thread 'main' panicked at 'DatagramBuffer.write_to() called while empty', src/relay/datagram_buffer.rs:71:9                                                                                                                                  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace 

Backtrace is the following

stack backtrace:                                                                                                                                                                                                                              0: backtrace::backtrace::dbghelp::trace                                                                                                                                                                                                              
    at C:\Users\VssAdministrator\.cargo\registry\src\github.aaakk.us.kg-1ecc6299db9ec823\backtrace-0.3.44\src\backtrace\dbghelp.rs:88                                                                                                        1: backtrace::backtrace::trace_unsynchronized                                                                                                                                                                                                        
    at C:\Users\VssAdministrator\.cargo\registry\src\github.aaakk.us.kg-1ecc6299db9ec823\backtrace-0.3.44\src\backtrace\mod.rs:66                                                                                                            2: std::sys_common::backtrace::_print_fmt                                                                                                                                                                                                            
    at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd\/src\libstd\sys_common\backtrace.rs:78                                                                                                                                        3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt                                                                                                                                                                 
    at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd\/src\libstd\sys_common\backtrace.rs:59                                                                                                                                        4: core::fmt::write                                                                                                                                                                                                                                  
    at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd\/src\libcore\fmt\mod.rs:1063                                                                                                                                                  5: std::io::Write::write_fmt                                                                                                                                                                                                                         
    at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd\/src\libstd\io\mod.rs:1426                                                                                                                                                    6: std::sys_common::backtrace::_print                                                                                                                                                                                                                
    at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd\/src\libstd\sys_common\backtrace.rs:62                                                                                                                                        7: std::sys_common::backtrace::print                                                                                                                                                                                                                 
    at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd\/src\libstd\sys_common\backtrace.rs:49                                                                                                                                        8: std::panicking::default_hook::{{closure}}                                                                                                                                                                                                         
    at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd\/src\libstd\panicking.rs:204                                                                                                                                                  9: std::panicking::default_hook                                                                                                                                                                                                                      
    at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd\/src\libstd\panicking.rs:224                                                                                                                                                 10: std::panicking::rust_panic_with_hook                                                                                                                                                                                                              
    at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd\/src\libstd\panicking.rs:470                                                                                                                                                 11: std::panicking::begin_panic                                                                                                                                                                                                            12: <F as relaylib::relay::selector::EventHandler>::on_ready                                                                                                                                                                               13: relaylib::relay::relay::Relay::run                                                                                                                                                                                                     14: gnirehtet::cmd_relay                                                                                                                                                                                                                   15: <gnirehtet::RunCommand as gnirehtet::Command>::execute                                                                                                                                                                                 16: gnirehtet::main                                                                                                                                                                                                                        17: std::rt::lang_start::{{closure}}                                                                                                                                                                                                       18: main                                                                                                                                                                                                                                   19: __tmainCRTStartup                                                                                                                                                                                                                                 at ./mingw-w64-crt/crt/crtexe.c:339                                                                                                                                                                                             20: mainCRTStartup                                                                                                                                                                                                                                    at ./mingw-w64-crt/crt/crtexe.c:223                                                                                                                                                                                             21: unit_addrs_search                                                                                                                                                                                                                      22: unit_addrs_search

Java version is not working either, spamming

2020-12-08 03:40:19.530 W UDPConnection: UDP 10.0.0.2:42221 -> 216.58.204.138:443 Cannot send to network, dropping packet
rom1v added a commit that referenced this issue Dec 8, 2020
In the Java version, a datagram was incorrectly rejected if its size was
exactly the remaining buffer size (this was harmless).

In the Rust version, the datagram buffer considered it had enough space
if a packet was 1 byte too big (causing packet overwriting).

Refs #345 <#345>
@rom1v
Copy link
Collaborator

rom1v commented Dec 8, 2020

Thank you for your report.

(the terminal text you pasted contains multicolumn text, which is confusing)

Cannot send to network, drop packet: Datagram buffer is full

thread 'main' panicked at 'DatagramBuffer.write_to() called while empty', src/relay/datagram_buffer.rs:71:9

Could you reproduce this crash often?

It should be fixed by 211db45, but it should happen rarely.

Cannot send to network, drop packet: Datagram buffer is full

I could not reproduce, but it means that the device sends a lot of UDP packets which could not be sent quickly enough on the client side.

Is it better with a bigger buffer?

diff --git a/relay-java/src/main/java/com/genymobile/gnirehtet/relay/UDPConnection.java b/relay-java/src/main/java/com/genymobile/gnirehtet/relay/UDPConnection.jav
a
index 6dd506c..5fec266 100644
--- a/relay-java/src/main/java/com/genymobile/gnirehtet/relay/UDPConnection.java
+++ b/relay-java/src/main/java/com/genymobile/gnirehtet/relay/UDPConnection.java
@@ -27,7 +27,7 @@ public class UDPConnection extends AbstractConnection {
 
     private static final String TAG = UDPConnection.class.getSimpleName();
 
-    private final DatagramBuffer clientToNetwork = new DatagramBuffer(4 * IPv4Packet.MAX_PACKET_LENGTH);
+    private final DatagramBuffer clientToNetwork = new DatagramBuffer(32 * IPv4Packet.MAX_PACKET_LENGTH);
     private final Packetizer networkToClient;
 
     private final DatagramChannel channel;
diff --git a/relay-rust/src/relay/udp_connection.rs b/relay-rust/src/relay/udp_connection.rs
index 936d578..d50403b 100644
--- a/relay-rust/src/relay/udp_connection.rs
+++ b/relay-rust/src/relay/udp_connection.rs
@@ -68,7 +68,7 @@ impl UdpConnection {
             socket,
             interests,
             token: Token(0), // default value, will be set afterwards
-            client_to_network: DatagramBuffer::new(4 * MAX_PACKET_LENGTH),
+            client_to_network: DatagramBuffer::new(32 * MAX_PACKET_LENGTH),
             network_to_client: packetizer,
             closed: false,
             idle_since: Instant::now(),

@xAt0mZ
Copy link
Author

xAt0mZ commented Dec 15, 2020

(the terminal text you pasted contains multicolumn text, which is confusing)

Sorry that's windows cmd 😬

Could you reproduce this crash often?

Basically tried to backup my 2000 4k photos onto google drive at once using google photos auto sync (using your product to use ethernet speed and avoid crappy wifi). This crash happens everytime after some time (approx 2 to 5 mins).

Is it better with a bigger buffer?

I will give it a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants