Android Question chat between two androids via a php server

hung

Active Member
Licensed User
Longtime User
I searched the forum but got no solution. The walkie talkie example is close but it is wifi. The no-io example require my phonr connect to local wifi then go mobile network.

I have two 3g android phones and one php server. How can i apply apply Walkie talkie example via 3g network directly? Phone - 3g - internet - php server - internet - 3g - phone

Both phones can use icanhazip.com to get public ip.

Thanks in advance.
 

sorex

Expert
Licensed User
Longtime User
it should work with those 2 dyndns names if nothing inbetween is blocking the ports you use.

no need for a php server.
 
Upvote 0

hung

Active Member
Licensed User
Longtime User
In the walkie talkie example I use the internet ip (get from icanhazip.com) to make Connect Wifi but "trying to connect" then failed to connect.

Do I need to use another connection method? the following is the ConnectWifi that I passed internet ip

B4X:
Public Sub ConnectWifi(Ip As String)
    socket1.Initialize("socket1")
    socket1.Connect(Ip, port, 30000)
    WifiStatus = "Trying to connect..."
    UpdateUI
End Sub
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
It should work but you need to apply some networking rules.

1. is a firewall blocking the request to port 30000
2. is there a forward rule in the firewall to your device for port 30000

On 3G networks there is probably nothing in between, unless your carrier is blocking none standard ports for security reasons.

I only have 1 phone so I can't test it for you.
 
Upvote 0

nwhitfield

Active Member
Licensed User
Longtime User
If you want to avoid firewall issues, which can be a pain in the neck when on mobile devices, then the way round it is to have each device talking to the server, probably using port 80, rather than talking directly to each other. There's a small performance penalty, but it's not very high - you can still get pretty much real time communication.
 
Upvote 0

KMatle

Expert
Licensed User
Longtime User
I have a MySql-Database on a server. With httputils2 you can send the text, sender, receiver etc. to a php script which inserts it to the db. With f.e. a timer or on demand you can get those messages (Select message from xxxx where receiver = 'me').

So you never need to care about firewalls, ip addresses, etc.
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
indeed, but he wants streaming between 2 devices so this doesn't really apply here as I don't see a use for it besides exchanging IP addresses.
 
Upvote 0
Top