Android Question Socket Connection Issue

aaronk

Well-Known Member
Licensed User
Longtime User
Hi,

I have an app which connects to a product by a SSL Socket and it sends ASCII messages and I get the reply etc. in my app.

On my phone (plus 1500+ other devices customers have in the field) my app works fine.

I have one customer whos phone is having an issue connecting with SSL.

I have developed a backend log in my app which I can view in a web browser to see what is happening in the background, and I find that it tries to make connection to the device using a SSL socket and then closes the socket pretty much straight away. The astream_Error sub get trigged as soon as the connection tries to make connection.

Using my Phone and connecting to the same IP/Port using a SSL Socket the connection gets made and works fine.

His phone is a Samsung (I think S5).

If I make a connection using a standard socket, (not SSL) then it connects fine and works. Only seems to be a SSL socket that is having the issue making connection.

Anyone else come across something like this or have any suggestions for me to try ?
 

aaronk

Well-Known Member
Licensed User
Longtime User
Are you using a self signed certificate?
Not sure, don't think so.

I don't have control over the device I am connecting to.

This is how I am initializing the SSL socket..

B4X:
so.InitializeSSLAcceptAll("so")
Dim r As Reflector
r.Target = so 'socket variable
r.Target = r.GetField("socket")
r.RunMethod4("setEnabledProtocols", Array(Array As String("TLSv1", "SSLv3")), _
Array As String("[Ljava.lang.String;"))

so.Connect(IP, port,5000)

The device I am connecting to only uses TLSv1 and the reason why I need to force the connection to use TLSv1 before making the connection.

This works fine on pretty much all devices except this one customer, where it seems to just give up straight away.
 
Upvote 0

aaronk

Well-Known Member
Licensed User
Longtime User
Is the Successful parameter true in the Connected event?
It returns false.

I port forward my device in my router and told the customer my IP/port to connect to. It allowed him to connect.

I then told the customer to enter in the IP/Port he was using and it failed.

I used the same settings in my phone and it allowed me to connect.

Using the same IP/Port, I told the customer to disconnect from the WiFi and as soon as he disconnected from WiFi he could connect. Connect back to WiFi and it failed to connect.

Found he had a Nat-Loopback issue. Well that is what I am putting it down to.
https://en.wikipedia.org/wiki/Network_address_translation#NAT_loopback

Strange thing is using a similar app on the iPhone it works on WiFi, so the customer says. (this iOS app wasn't written by me, and would be connecting the same way as I am).

I had to setup 2 different connections in the app, one when connected by WiFi locally and another while on 3G/4G.
 
Upvote 0

aaronk

Well-Known Member
Licensed User
Longtime User
I have another customer with the same issue, except this time it's connecting to the device using the Local IP address while connected to Wi-Fi.

Model: C6506
SDK: 22 (Lollipop)
Product: C6506
Manufacturer: Sony

Connection is done by WiFi and is connecting to the device using the local IP address (not the WAN IP)

Is the Successful parameter true in the Connected event?
It seems to return False.

This customer has also provided a .pcap capture file when trying to connect, but don't want to post it to the forum and I am not sure if it's going to help any?
 
Upvote 0

aaronk

Well-Known Member
Licensed User
Longtime User
(non wildcard) SSL certificates are tied to a specific ip address or host. You cannot use a different address with the same certificate.

The product I am connecting to can have a different IP address. I can change the IP address to something else and connect to it with no issues.

I have no control over this product I am connecting to.

This customer then tries to connect and it fails. Well to his product it fails.

There is a computer program which connects to this product as well, and that software is working fine using the same IP/port at the customers house. (this software wasn't written by me)

So this issue seems to be something to do with the Android device in the way it's connecting to the device.
 
Upvote 0

aaronk

Well-Known Member
Licensed User
Longtime User
You need to check the logs and see whether there is any more information.
Do you mean the logs in the IDE ?

If so this is on the customers phone who is on the other side of the world than me.

Using my phone everything is working fine, so I can't check at my side.

This customer said he viewed the catlog from his phone, but I am not sure if he knows what he was looking for. If I was to get this file would it help? (I personally not sure 100% how to read this file)
 
Upvote 0
Top