ToyVPN unable to connect to VPN Server - android

I am experimenting with the new VPNService API with the sample project "ToyVPN". I have not modified the source code and it compiles smoothly, but I cannot seem to get it to connect to my VPN server on ec2. It times out with the error "Got java.lang.IllegalStateException: Timed out". From the server's perspective, no packets are being received from the phone.
I am entering in the ip address of the server, 1723, and my password for server address, server port, and shared secret respectively.
I am able to connect to my vpn server using the default ubuntu vpn manager over pap authentication using the same password.
Can someone offer insights on what is going on and how I can make ToyVPN connect to my server?

What about sample server implementation from "ToyVPN" project? Why don't you use it?
It is easy to set in Linux, all steps and limitations are described in ToyVpnServer.cpp file. Certainly at first you should compile it. I compile it using GCC package:
gcc ToyVpnServer.cpp
Program file named "a.out" will be created in the same directory.
Then just run it from command line with the parameters that described in ToyVpnServer.cpp.
It is strange, that you don't see any packets on the your VPN server side. I tried to connect to my VPN server through ToyVpn just to see what will happen. Connection was failed, but there were messages in server logs, that the packets are received, but its size is too small.
Hope this will help.

Related

How to configure HiveMQ client serverHost, serverPort & sslConfig for SSL connect to port 8883?

Having read some docs and all examples I could find, I do not see a very simple example of connecting by SSL to 8883. It was very simple to create the HiveMQ client on Android to connect to the broker at mosquito.org, port 1883. But using credentials that I generated there, when trying to connect to port 8883 fails and this log message is seen:
MacAddressUtil com.example.tryhive W Failed to find a usable hardware address from the network interfaces; using random bytes: f4:51:aa:f9:c6:c8:9d:fa
I am just following simple examples for client creation:
mqttClient = MqttClient.builder()
.useMqttVersion3()
.identifier(“MyID”)
.serverHost("test.mosquitto.org")
.serverPort(8883)
.sslConfig()
.keyManagerFactory(managers.kmf)
.trustManagerFactory(managers.tmf)
.applySslConfig()
.buildAsync()
The key manager and trust manager factories, built with the credentials created at mosquito.org work to make a TLS connection using the Paho MqttAndroidClient in a different Android app - should I post those here as well anyway?
I tried to use a similar serverHost as done with Paho client:
.serverHost("ssl://test.mosquitto.org")
.serverPort(8883)
But that results in an exception being thrown in Netty.
Also interesting to note is that when I first ran the non-secure client, I inadvertently left in the uri used with Paho Client, so this:
.serverHost(“tcp://test.mosquitto.org”)
.serverPort(1883)
And that as well caused the connection to fail with the same MacAddressUtil log above:
MacAddressUtil com.example.tryhive W Failed to find a usable hardware address from the network interfaces; using random bytes: f4:51:aa:f9:c6:c8:9d:fa
That is why I didn’t clutter this post with the code that creates the Key and Trust Manager Factories passed to the sslConfig() - it seems that the error is somewhere else.
Please share any sample code that works for you or lessons you learned wrt this using HiveMQ yourself.
Update 2022/12/05:
Suspecting an issue in Netty, I've tried using their latest release to no avail:
dependencies {
implementation 'com.hivemq:hivemq-mqtt-client:1.3.0'
implementation(platform("io.netty:netty-bom:4.1.85.Final"))
Still cannot connect with HiveMQ client to any mosquitto secure ports: 8883, 8884, or 8885.
So I tried to go in through the websocket interface with this:
implementation 'com.hivemq:hivemq-mqtt-client-websocket:1.3.0'
and of course adding to the MqttClient.builder():
.webSocketWithDefaultConfig()
Then it connects without .sslConfig() to mosquitoo port 8080
But then enabling SSL, connections fail to ports 8081, 8090 & 8091
I know that this seems to point more to an error in my implementation of the KeyManagerFactory and/or the TrustManagerFactory, but the identical code to build them is used in an app that uses the Paho client, and secure connection succeeds.

WebRTCDemo apk fetch wrong addresses from STUN/TURN server

following http://www.webrtc.org/native-code/android, the WebRTCDemo apk I built runs well on my android device and can start video calls with Chrome. the issue is 1) the apk failed to establish connections with peers when in different LANs, 2) but two Chromes can succeed to start p2p calls.
after checking the log I found the apk gives wrong candidate transport addresses. my private address is 10.10.10.108 and the public address is 112.10.45.196, the apk will send the following transport addresses to room server:
10.0.2.15
10.10.10.108
10.236.188.19
..ipv6..
so it is odd that where the apk learned these tow addresses:
10.0.2.15
10.236.188.19
after sniffing traffic using WireShark, I did not found any clue, the TURN/STURN server respond with correct values.
so anyone knows why?

Spring Android Connection Refused ECONNREFUSED

I am trying to make a connection from my Android to my local machine on a wifi network. My machines wifi ip address is 10.27.27.172 and I am running my node.js server on port 7890. I can use my phones chrome browser and browse to my server and access some endpoints which return json. My problem comes when I try and use spring-android rest template. I have given INTERNET permissions to my android application but I still get a ECONNREFUSED error. Is this an android port issue? Is the firewall blocking my request. If so why can I browse to the server but not use the REST client to get the information?
I found the answer on this stackoverflow. You need to make sure you retype the I guess the eclipse editor sometimes adds in invisible characters or something. Anyways it is working now.

SmartFoxServer unable to connect to server

I am working in android chat application.
I used SmartFox server. I am using 10.0.2.2 as server IP address and 9933 as Port.
Whenever i run this application using emulator then works fine but when i run this application in my real device then connection does not performed correctly. I think this is unable to find out IP 10.0.2.2.
I changed this IP address to 192.168.1.9 which is IP address of my system in LAN on which SmartFox server is installed.
Please suggest me what mistake i have done.
Thank you in advance.
I resolved my problem myself. I created one entry in confi/server.xml file of server.
like this:-
<serverSettings>
<socketAddresses>
<socket address="192.168.1.9" port="22" type="TCP"/>
<socket address="192.168.1.9" port="22" type="UDP"/>
</serverSettings>
</socketAddresses>
or you may add this entry using admin module of Smartfox server. This task can be done using Server configuration part.

How to debug http calls on Android devices?

I'm writing a Lovefilm client for Android, and it's not going too badly except I keep having problems with the remote calls to retrieve data from the API.
Does anyone have any tips for debugging remote calls like this? Can I tcpdump on Android or is there a native way of doing it?
For example, I'm using the Scribe-java library for OAuth to access the Lovefilm API, I can authenticate find and retrieve a list of films on the users account fine when the device is running Gingerbread, but trying to retrieve the accessToken on Froyo causes a blank response & and apparent response code of -1, I'd like to be able to see what's going on under the cvers their.
Another example I'd like to be able to the raw http for is trying to run a search, I get and IOError that says "Received authentication challenge is null"
I've used Fiddler (http-proxy for debugging http calls) with the android emulator in these cases. Just start the proxy, and start the emulator with the correct proxy address (-http-proxy ).
Fiddler is the most useful option. On the emulator #Scythe answer will work, but on a real device you will need to set the proxy in the Apache Http Client. The following code will do that:
HttpHost proxy = new HttpHost("youripaddr", 8888);
params.setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
If you are using https, fiddler is not so useful. In that case can enable the build in logging support in Apache Http Client. The following code does that:
Headers only:
java.util.logging.Logger apacheHeaderLog = java.util.logging.Logger.getLogger("org.apache.http.headers");
apacheHeaderLog.setLevel(java.util.logging.Level.FINEST);
Headers & Wire:
java.util.logging.Logger apacheWireLog = java.util.logging.Logger.getLogger("org.apache.http.wire");
apacheWireLog.setLevel(java.util.logging.Level.FINEST);
Note that this will have to have a java.util.logging Handler configured at finest level and the default handler is configured to log to logcat, which will filter DEBUG (finest) entries by default.
If your system can share the wi-fi connection you should be able to route packets from any device through your system and then using wireshark you can get monitor your calls or get a tcpdump.
Also , and more importantly , it would be best if you log your network calls and responses as suggested by #Matthew
Windows 7 wi-fi connection sharing : http://www.winsupersite.com/article/faqtip/windows-7-tip-of-the-week-use-wireless-hosted-networking-to-share-an-internet-connection-wirelessly.aspx
Since I always run into similar troubles and it seems a lot of people having the same issues over and over again I wrote up a quick tutorial for debugging client-server communication by using netcat and cURL.
That of course only works for the simplified case that you always 'fake' on side of the connection.
For eavesdropping you can use tools like tcpdump or Wireshark. Which will definitely be easier if you're able to run the server instance directly on your local machine.
Stetho is a great tool from FB which helps in debugging android Apps. You can have access to local data and have a check on your network using this.
http://facebook.github.io/stetho/

Categories

Resources