EINVAL (Invalid argument)
When trying to write to vpn output with vpnOutput.write(bufferFromNetwork), the java.io.IOException: write failed: EINVAL (Invalid argument) is thrown. It happens on several phones.
It is ok for some requests, but for some I get this exception and then the vpn stops working.
In the LogCat I can see several java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer) errors.
Can you point me to the solution of this?
Thanks
Have you ever found the solution to this or a cause?
OK, I have found the cause in my case. Looks like bad/corrupted IP headers may cause this error.
I was trying to create a tun tunnel between socat and my own VpnService implementation.
socat was prepending each data packet with 4 bytes, which turned out to be a "Packet Information" (see https://www.kernel.org/doc/Documentation/networking/tuntap.txt for the IFF_NO_PI ifreq flag). So, adding the iff-no-pi option to the socat tun has stopped prepending each packet with 4 extra bytes and thus solved the problem for me.
@KostyaEsmukov @hexene Hi, i am trying to build a own VpnService with Raw socket implementation. Could you give me some help on receiving packet and how to write packet to tun? Thanks for your help
@Dojav
How is that related to this project? If you want to contact anyone directly – please use email for that instead of an issue tracker of some project.
Stack Overflow is even a better venue for questions than private email communications, and chances for getting help there are much higher.
And before asking for help, please make some effort to solve your issue by yourself and present the problem such as it's easy to grasp. Stack Overflow has a great writing on asking questions mannerly: https://stackoverflow.com/help/how-to-ask
@KostyaEsmukov So your fix was not in the LocalVPN source files?
@mikelibg I've never used LocalVPN. As I said, I was working on my own implementation of VpnService. This issue just was the first result popping out on Google back in 2016. As I solved my issue, I shared the cause which might be helpful in resolving this issue in LocalVPN itself.