slowscript / warpinator-android

An unofficial implementation of Warpinator for Android
GNU General Public License v3.0
481 stars 29 forks source link

Doesn't seem to work with Winpinator v0.1.2 #113

Closed 1oh1 closed 2 years ago

1oh1 commented 2 years ago

Hey there, I tried using the app with Winpinator v0.1.2 and it seems to work fine initially in the first 5-10 minutes or so but then stops working and I see the Windows hosts listed as null@hostname and I can't send anything from my phone to the Windows hosts and on the Windows hosts, the phone is listed as offline.

I am using warpinator-android version 1.4.6. I am also using Wireguard on both my phone as well as my Windows hosts but I've configured split tunnelling and added Warpinator to the excluded apps list so it doesn't interfere with Warpinator. However, I also run into the issue even when Wireguard is turned off on both the PC and the phone. The behavior is exactly the same with or without Wireguard connected. I've opened UDP ports 40000-40001 as well.

Looking at the Android logs, I see a lot of messages with this:

09-05 03:25:35.138 17083 31264 D Remote  : Certificate for LARA received and saved
09-05 03:25:35.143 17083 31264 E gedChannelOrphanWrapper: *~*~*~ Channel {0} was not shutdown properly!!! ~*~*~*
09-05 03:25:35.143 17083 31264 E gedChannelOrphanWrapper:     Make sure to call shutdown()/shutdownNow() and wait until awaitTermination() returns true.
09-05 03:25:35.143 17083 31264 E gedChannelOrphanWrapper: java.lang.RuntimeException: ManagedChannel allocation site
09-05 03:25:35.143 17083 31264 E gedChannelOrphanWrapper:   at io.grpc.internal.ManagedChannelOrphanWrapper$ManagedChannelReference.<init>(ManagedChannelOrphanWrapper.java:5)
09-05 03:25:35.143 17083 31264 E gedChannelOrphanWrapper:   at io.grpc.internal.ManagedChannelOrphanWrapper.<init>(ManagedChannelOrphanWrapper.java:3)
09-05 03:25:35.143 17083 31264 E gedChannelOrphanWrapper:   at io.grpc.internal.AbstractManagedChannelImplBuilder.build(AbstractManagedChannelImplBuilder.java:33)
09-05 03:25:35.143 17083 31264 E gedChannelOrphanWrapper:   at slowscript.warpinator.Remote$$ExternalSyntheticLambda0.run(Unknown Source:78)
09-05 03:25:35.143 17083 31264 E gedChannelOrphanWrapper:   at java.lang.Thread.run(Thread.java:920)
09-05 03:25:35.144 17083 31264 E gedChannelOrphanWrapper: *~*~*~ Channel {0} was not shutdown properly!!! ~*~*~*

There was also this:

09-05 03:27:57.112 17083 31782 E Remote  : Couldn't establish duplex with PN50
09-05 03:27:58.033 17083 31690 D Remote  : Connection interrupted while waiting for duplex
09-05 03:27:58.033 17083 31690 D Remote  : io.grpc.StatusRuntimeException: UNAVAILABLE
09-05 03:27:58.033 17083 31690 D Remote  :  at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:11)
09-05 03:27:58.033 17083 31690 D Remote  :  at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:10)
09-05 03:27:58.033 17083 31690 D Remote  :  at slowscript.warpinator.Remote$$ExternalSyntheticLambda0.run(Unknown Source:102)
09-05 03:27:58.033 17083 31690 D Remote  :  at java.lang.Thread.run(Thread.java:920)
09-05 03:27:58.033 17083 31690 D Remote  : Caused by: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.

I've attached logs from when it worked as well as when it didn't if that helps with troubleshooting the issue.

Thank you for creating the app!

1oh1 commented 2 years ago

failure.log success.log (success establishing duplex connection with Lara)

slowscript commented 2 years ago

Hi, this could be caused by a poor WiFi connection between your phone and the PC. It is the easiest explanation why it would suddenly stop working and say "Connection interrupted" or anything about improper channel shutdown.

The logs don't show anything interesting, only that the phone is trying to connect to the other devices and they are not connecting back (duplex/both-ways connection). The connection also sometimes gets broken while waiting for the other side. If you believe your WiFi signal is good then maybe something on the other side is breaking the connection. I'm not familiar with how Winpinator works but having logs from the other side could still be useful.

You wrote that the other side sees the phone but shows it as offline. I don't see a button to force reconnect in Winpinator, so maybe try a reannounce in the Android app? Although I see you restarted the app a couple of times so that is basically the same thing. If you made a reannouncement (or restarted the app) and the other side is still showing the phone as offline (even after a while - not sure how often Winpinator retries connection) then the mDNS packets (UDP port 5353) must be getting lost somewhere.

The only other piece of advice I can offer is that when your WiFi has limited connectivity to the Internet, there is this strange behavior that Android will tell the app that there is WiFi, but in fact route some (possibly the multicast device announcement & discovery) packets through the cellular connection. Turning off data fixes this for me.

Sorry for not giving a definitive answer but what you are seeing is most likely a network issue and these are really hard to diagnose, especially when I only see one side of the communication.

Edit: You can also try my implementation of the Windows application but I'm afraid the issue will persist. Also according to the logs the port is 42000, not 40000, although I expect this to be just a typo.

1oh1 commented 2 years ago

Thank you so much for the detailed explanation of the issue. I don't think the problem might lie with my Wi-Fi as signal strength is pretty good. I also tried disabling mobile data with only Wi-Fi turned on and that didn't help either. I did once see a certificate related error in the app once with a popup saying, "Failed to receive the certificate from my LARA...".

I tried your Windows port of Warpinator and it seems to work perfectly and I don't run into any issues either in the beginning or later on after a few minutes and even after my phone goes into power saving mode and kills the warpinator-android service and I start it again. It's able to detect the Windows host (Lara) and connect it to it every time.

So maybe the issue might lie with Winpinator or the way it implements the Warpinator protocol? I noticed the README said "Support both Warpinator registration protocols (v1 and v2)"

Success logs from warpinator-android with warpinator-windows running as server: warpinator-android-with-warpinator-windows.log

Failure logs (minimal logs) from warpinator-android with Winpinator running as server: warpinator-android-failure-with-winpinator.log

I raised this issue with Winpinator as well: https://github.com/swiszczoo/winpinator/issues/35

slowscript commented 2 years ago

I did once see a certificate related error in the app once

Probably an odd case, the logs say that the certificate was received correctly most of the time

I noticed the README said "Support both Warpinator registration protocols (v1 and v2)"

Well, this is how it should be - it's what the Linux original does. My versions are actually different and don't support v2 because I don't find it to be much of an improvement and running both versions for compatibility seems like a hassle and a source of bugs. So, maybe Winpinator's v1 implementation is buggy in some rare cases? Or my implementation is buggy but in a compatible way? Or would it be better for me to also support v2, even though I've never had any issues connecting with v1 (not even with Winpinator)?

1oh1 commented 2 years ago

Honestly, I don't know what's the difference between v1 and v2. As long as it works on both Windows and Android, I'm good with it and since your Windows implentation works perfectly, without any issues, I think I'll be switching over from Winpinator.

Thanks again! Shall I resolve the issue?

slowscript commented 2 years ago

Sure, you can resolve the issue. I'm happy to hear my version is working better. We'll see if the author of Winpinator will investigate the issue you filed in his repo and in case the problem is on my side, someone will hopefully create another issue with more insight on what could be the cause of the incompatibility.