ServerSocket Not Returning Correct IP

margret

Well-Known Member
Licensed User
Longtime User
I am having an issue where the first time I run the code below, it returns the IP I have set. If I then go back and change the IP and run this code again. It shows the IP that I used the first time and not the current one. Do you see what I am doing wrong? The device is a tablet and has only one WiFi connection.

B4X:
Dim MyLan As ServerSocket
MyLan.Initialize(0, "")
MyLan.Listen
Msgbox(MyLan.GetMyIP, "")
 

nw11

Member
Licensed User
Longtime User
I have the same problem .. the IP address that should be returned (and where the device is listening) have to start with 151.x. ecc. ecc. (that is the prefix of my internet provider "wind") .. sometimes the serversocket listen to the right IP Address .. but .. sometimes the address returned start with 10.x.x ( that is not even my local network prefix .. it start with 192.168.x.x ) .. in this case the device is unreachable by my client App .. any idea of how to fix ? Please help me.

nb: i always made refer to a mobile connection



sorry for my english
 
Last edited:
Upvote 0

nw11

Member
Licensed User
Longtime User
ServerSocket.GetMyIp returns the IP reported from the network driver.

If a wireless IP is available then it will return the wireless IP address.

Thank you for your replay.

My wi.fi. is deactivated by the device button .. so the ip address returned (10.x.x.x) is not of my local network and not of my wi.fi network .. Both start with 192.168.x.x

I dont know where this ip address is returned from .. All i know is that when i receive 10.x.x.x ip address server socket service of my server app is unreachable while when it return the right ip address 151.x.x.x (the same ip returned from whatsmyip.asp of http command) i can connect and send message correctly.

How can i fix ?

Thank you in advance.
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
@nw11

Are you using the latest Network-library?

(updated to 1.20 in this post
http://www.b4x.com/forum/additional-libraries-classes-official-updates/18993-network-library.html#post109077

I also have users reporting similar problems. I still need to distribute new versions of my apps (with updated library) to those having said problem and unfortunately I cannot reproduce it myself so in this moment I cannot say if the new library resolves the problem or not. Have a go and let us know unless you are already using version 1.20.

Edit: I noted that with B4a 2.02, there is already a newer version of the network-library (1.21)
 
Upvote 0

nw11

Member
Licensed User
Longtime User
unfortunately I'm already using the Network Lib Vers. 1.21
 
Last edited:
Upvote 0

rbsoft

Active Member
Licensed User
Longtime User
My wi.fi. is deactivated by the device button .. so the ip address returned (10.x.x.x) is not of my local network and not of my wi.fi network .. Both start with 192.168.x.x

I dont know where this ip address is returned from .. All i know is that when i receive 10.x.x.x ip address server socket service of my server app is unreachable while when it return the right ip address 151.x.x.x (the same ip returned from whatsmyip.asp of http command) i can connect and send message correctly.

Mobile network providers do not allow incoming connections!

Your 10.x.x.x ip address is a mobile connection ip. If your app is supposed to run as server you can do so only in Wifi connections.

Rolf
 
Upvote 0

nw11

Member
Licensed User
Longtime User
I'm sorry .. but i don't think so. Usually i get the correct ip address (151.x.x.x) .. Sometimes (about once every five) i will receive the address 10.x.x.x.

If my network provider will not allow me to access my device on serversocket mode i should always receive 10.x.x.x

Maybe is a random error of network driver or network library.
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
I'm sorry .. but i don't think so. Usually i get the correct ip address (151.x.x.x) .. Sometimes (about once every five) i will receive the address 10.x.x.x.

If my network provider will not allow me to access my device on serversocket mode i should always receive 10.x.x.x

Maybe is a random error of network driver or network library.

Do you use your server socket with a PC? I've noticed that occasionally my pc network is losing its local IP and adjust to my wireless 3g ip. Not always, just sometimes. I tend to blame Vista for this, but as I said, I don't know your configuration.
 
Upvote 0

rbsoft

Active Member
Licensed User
Longtime User
What network provider are you using and in which country? Rules for the use of mobile networks differ, here in Germany the network providers usually do not allow using a mobile connection for server purposes, unless you have a special M2M contract.

You can try from your mobile this link: What Is My IP - Shows Your IP Address

It will probably report two IP's - the real one (151...) and a proxy (10...). You would need the real IP to communicate with the device. More info you can find here:
Mobile IP - Wikipedia, the free encyclopedia

Rolf
 
Upvote 0

nw11

Member
Licensed User
Longtime User
thank you for your replay .. the serversocket app is installed on a mobile device which have to receive connection and push message from another app installed on a mobile device. the pc is used only for sincronize the ip address that should be called (receive the ip address from the server socket when it change reporting from the phone events that send the new ip to pc server). the problem is that sometimes it return a wrong ip address (10.x.x.x) that result unreachable. i think this is not a network provider problem.

i"m in italy and my provider is wind .. but i'm receiving this problem from my beta tester in oher countrys with other network mobile provider.

as i already said in a precedent post .. i'm already using "what is my ip" mobile service to receive the real ip address .. is in this way that at moment i can point out the problem .. but unfortunatly i can't force the server socket listen command on the right and real ip address .. it is an automatic procedure that the network lib do by it self. it receive 10.x.x.x wrong ip and listen on this ip so it result unreachable.

i dont know if make the listen command able to listen on a user inserted ip address (in this case always the real one) could be the solution ..

thank you all in advance ..
 
Last edited:
Upvote 0

nw11

Member
Licensed User
Longtime User
What network provider are you using and in which country? Rules for the use of mobile networks differ, here in Germany the network providers usually do not allow using a mobile connection for server purposes, unless you have a special M2M contract.

You can try from your mobile this link: What Is My IP - Shows Your IP Address

It will probably report two IP's - the real one (151...) and a proxy (10...). You would need the real IP to communicate with the device. More info you can find here:
Mobile IP - Wikipedia, the free encyclopedia

Rolf

now i have received from server socket "MyIP" command the ip address -- >

10.2.207.113 (network lib is listen here at the moment but unreacheable)

and from What Is My IP - Shows Your IP Address --> this message

Your IP Address Is: 151.25.9.153
No Proxy Detected

any idea ? please help !!
 
Upvote 0

nw11

Member
Licensed User
Longtime User
The external IP address is usually not relevant. Your router gives a local ip address to each device in the network. See this link for more information: Network address translation - Wikipedia, the free encyclopedia

thank you Erel for your replay ..

as a wrote in my previous post :

the IP address that should be returned (and where the device is listening) have to start with 151.x. ecc. ecc. (that is the prefix of my internet provider "wind") .. sometimes the serversocket listen to the right IP Address .. but .. sometimes the address returned start with 10.x.x ( that is not even my local network prefix .. it start with 192.168.x.x ) .. in this case the device is unreachable by my client App .. any idea of how to fix ? Please help me.

nb: i always made refer to a mobile connection (not wi.fi)


sorry for my english
 
Last edited:
Upvote 0

nw11

Member
Licensed User
Longtime User
This is the IP address returned from the network driver. It may be a bug in the driver.

i'm already using "what is my ip" mobile service to receive the real ip address .. is in this way that at moment i can point out the problem .. but unfortunatly i can't force the server socket listen command on the right and real ip address .. it is an automatic procedure that the network lib do by it self. it receive 10.x.x.x wrong ip and listen on this ip so it result unreachable.

i dont know if make the listen command able to listen on a user inserted ip address (in this case always the real one) could be the solution ..

do you think is a possible solution to work around .. and .. it's technically possible modify the network lib to do this ?

thank you in advance !!!
 
Upvote 0

nw11

Member
Licensed User
Longtime User
The device result unreachable when it automatically listen at 10.x.x.x ip even if i try to connect at real ip address 151.x.x.x

while it is perfecly reachable when it listen at the correct real ip address (151.x.x.x)
 
Last edited:
Upvote 0
Top