1

I'm pretty new to Android programming and I had a little project for an Android VPN firewall-sortofthing in mind, based on this GitHub repo: https://github.com/hexene/LocalVPN (so on top of VpnService)

The problem is that, no edits done to the code from the original repo, the VPN stops working after a while (after seconds usually). By that I mean internet connection is lost in all applications, so I guess packets stop flowing through the VPN. It happens randomly and seemingly with no triggering event. Again, I edited 0 lines from the code.

What I've tried so far is:

  • Using startForeground() as suggested here. Nothing changes.
  • Having a permanent high priority notification showing to prevent the service from stopping (although I don't know if the service stopping is the cause.
  • Only allowing certain apps in the VPN with Builder.addAllowedApplication(). This didn't work, as expected.

Anyone have any ideas or wisdom to share? Would be much appreciated!

Edit: the Log, when internet stops working, says this:

03-16 00:52:18.904 13182-13260/xyz.hexene.localvpn E/TCPInput: Network read error: 172.217.23.67:443:42746
                                                           java.io.IOException: Connection reset by peer
                                                               at sun.nio.ch.FileDispatcherImpl.read0(Native Method)
                                                               at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43)
                                                               at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)
                                                               at sun.nio.ch.IOUtil.read(IOUtil.java:192)
                                                               at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:382)
                                                               at xyz.hexene.localvpn.TCPInput.processInput(TCPInput.java:133)
                                                               at xyz.hexene.localvpn.TCPInput.run(TCPInput.java:72)
                                                               at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
                                                               at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                               at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
                                                               at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
                                                               at java.lang.Thread.run(Thread.java:776)
DmitryB
  • 119
  • 1
  • 2
  • 13
  • Having the same issue, also tried your steps and it didn't work. I'm getting the same output in LogCat, if you solve this do let me know. Thanks :) – user3307598 Mar 22 '18 at 00:55
  • Actually I already solved it but just for my particular implementation. I just needed a running local VPN that throws all incoming packets except from certain apps. So for me the solution was deleting everything except the strictly necessary to make the VPN start, and then calling addDisallowedApplication("appname"). – DmitryB Mar 22 '18 at 22:41
  • Hey, I found a github repository that might help! I already knew it but it wasn't working, now the developer fixed it: https://github.com/LipiLee/ToyShark – DmitryB Mar 26 '18 at 17:59
  • Could you share the commit in which he fixed it? – Adrián García Campos Oct 30 '18 at 14:45
  • He didn't fix the issue I made the question about if I remember correctly, it's just another repository – DmitryB Nov 05 '18 at 20:40

0 Answers0