Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Tue Oct 16, 2018 4:16 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: sockets and public ip not working
PostPosted: Sun Nov 25, 2012 4:32 pm 
Offline

Joined: Sun Nov 25, 2012 4:23 pm
Posts: 4
Location: France
Good morning,
I have gone through the sample network applications ServerSocketServerTest and ServerSocketClientTest.
They work fine with local ip. But as soon as I change the socket address to my public ip, the client does not
connect to the server.

I did open the correct port on my router to forward it to the server (and checked that the port was open with http://www.yougetsignal.com/tools/open-ports/).

Is there something I am missing, any hint?

Thank you for your help.


Top
 Profile  
Reply with quote  
 Post subject: Re: sockets and public ip not working
PostPosted: Sun Nov 25, 2012 4:49 pm 
Offline
Real Software Engineer

Joined: Sat Dec 24, 2005 8:18 pm
Posts: 7858
Location: Canada, Alberta, Near Red Deer
that the server is what listens on the port & the socket that is actually dealing with the client from the server may be on some other port (otherwise the server could not continue to listen on it)

http://docs.realsoftware.com/index.php/ServerSocket

_________________
Norman Palardy (Real Software)


Top
 Profile  
Reply with quote  
 Post subject: Re: sockets and public ip not working
PostPosted: Sun Nov 25, 2012 6:47 pm 
Offline

Joined: Sun Nov 25, 2012 4:23 pm
Posts: 4
Location: France
Really weird...
I tried with several ports 1501, 1503, 8888 and those work fine when the Address property is set to "localhost", or "127.0.0.1" or with my local ip "192.168.1.96"

Still cannot get this to work when I set it to my public ip address!


Top
 Profile  
Reply with quote  
 Post subject: Re: sockets and public ip not working
PostPosted: Sun Nov 25, 2012 7:52 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
Try it with a simple TCPSocket on each end. The server side listens, the client connects. If you can't get that working, then you still have firewall issues.


Top
 Profile  
Reply with quote  
 Post subject: Re: sockets and public ip not working
PostPosted: Sun Nov 25, 2012 8:10 pm 
Offline

Joined: Tue Mar 23, 2010 8:44 pm
Posts: 673
Lourenco wrote:
Good morning,
I did open the correct port on my router to forward it to the server (and checked that the port was open with http://www.yougetsignal.com/tools/open-ports/).

Is there something I am missing, any hint?

Thank you for your help.



This might be wrong because my memory isn't so sharp right now but doesn't the actual port number change when using server socket?

It may accept the connection on one port (designated) then switch ports to handle the connection?

I seem to recall something like that or maybe I'm remembering something else?

So you could set the port for 5000 but it might end up using 35000 or others.

I could be remembering something else - FTP?

Another possible issue is you may have other software blocking certain network traffic. Something like little snitch for instance. When I say other I mean something different than your firewall software/hardware.


Top
 Profile  
Reply with quote  
 Post subject: Re: sockets and public ip not working
PostPosted: Sun Nov 25, 2012 8:15 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
You are correct that it changes ports, but since the communication on that port is initiated by the server, the router should allow it.


Top
 Profile  
Reply with quote  
 Post subject: Re: sockets and public ip not working
PostPosted: Mon Nov 26, 2012 4:31 am 
Offline
User avatar

Joined: Sun Oct 28, 2012 4:54 am
Posts: 264
Location: Herts, UK
Why would you be setting the socketserver IP address to a public IP..?

I presume that you have a NAT router in which case all you would need to do is to set the serversocket to a private IP IE: 192.168.1.100 and to add a port forward rule/mapping on the router to point to the private address.

_________________
Real Studio 2012 R2
SysInfo
BackTrack Linux/BackBox Linux/Debian Lenny/Windows 7/Windows 8/OpenWRT/OpenBSD
& Yes it's me in the Avatar


Top
 Profile  
Reply with quote  
 Post subject: Re: sockets and public ip not working
PostPosted: Mon Nov 26, 2012 10:44 am 
Offline
User avatar

Joined: Fri Oct 28, 2005 7:05 am
Posts: 565
Location: Emsworth, UK
Lourenco wrote:
Still cannot get this to work when I set it to my public ip address!
Are you by any chance running the server application on the same host (PC) as you are running the client application and the PC is behind a NAT router?

If so, your facing a routing problem (nothing to do with firewalls).

[PC 10.0.0.10/24] <--> [10.0.0.1/24 |NAT| 123.123.123.123/32] <- the internet ->
/24 refers to the subnet mask 255.255.255.0 and /32 is 255.255.255.255

Do you see the problem?
The public IP 123.123.123.123 is on a different subnet to your PC.

A virtual IP address on the PC and a static route on the router, can get some NAT routers over the issue. Many cheap domestic routers just don't support it at all.

_________________
Yes it's me in the avatar


Top
 Profile  
Reply with quote  
 Post subject: Re: sockets and public ip not working
PostPosted: Mon Nov 26, 2012 5:00 pm 
Offline

Joined: Sun Nov 25, 2012 4:23 pm
Posts: 4
Location: France
That's it I set a port forward rule on the router to point all incoming connections on port 1501 (this is the port number the server is listening) to the IP address of the server.

Then in the client application I set the public ip address of my router and the port 1501.
So every connection to the public ip on port 1501 is routed to the server.
But the client never connects.

For debugging, I set a msgbox prompt on the server side whenever a connection is done.

And when I use the following url :
http://www.yougetsignal.com/tools/open-ports/
to check my port, the server traps the connection and displays the message box.

So everything is ok with the router, the port and the server.
But the client never connects :-(


Top
 Profile  
Reply with quote  
 Post subject: Re: sockets and public ip not working
PostPosted: Tue Nov 27, 2012 3:54 pm 
Offline

Joined: Fri Nov 16, 2007 10:18 pm
Posts: 195
Location: Portland, OR
Lourenco wrote:
I set a port forward rule on the router to point all incoming connections on port 1501 (this is the port number the server is listening) to the IP address of the server.


Where is the client? On the inside already? Your router is only routing traffic coming in from the outside. Your local network still must connect to the local address. Some routers will reroute internal traffic back in but most cheap ones will not.

Public Clients
|
Internet Public Address space
|
Router
|
Local Address space
|
+-- Server (192.168.1.100)
|
+-- Local client (192.168.1.101)


eta: Have you tried using an outside proxy to hit your site? Just bounce your client against any available outside proxy so that you would see what the internet sees.

_________________
Windows: Win7 64bit sp1, Vista 32bit sp2, WinXP 32bit SP3
Linux: RH EL6
Mac: Died in 2011 and took 2 months to notice.

RealStudio: 2012r2


Top
 Profile  
Reply with quote  
 Post subject: Re: sockets and public ip not working
PostPosted: Wed Nov 28, 2012 6:58 am 
Offline
User avatar

Joined: Sun Oct 28, 2012 4:54 am
Posts: 264
Location: Herts, UK
What Operating system are you hosting the Server Application on..?

Maybe windows firewall /IPtables etc... is blocking access to the listening port.

:?:

_________________
Real Studio 2012 R2
SysInfo
BackTrack Linux/BackBox Linux/Debian Lenny/Windows 7/Windows 8/OpenWRT/OpenBSD
& Yes it's me in the Avatar


Top
 Profile  
Reply with quote  
 Post subject: Re: sockets and public ip not working
PostPosted: Thu Nov 29, 2012 5:17 pm 
Offline

Joined: Sun Nov 25, 2012 4:23 pm
Posts: 4
Location: France
The problem is resolved. :-)

Indeed Bob, as you mentioned, my router is only routing traffic coming in from the outside.
And as my server and client were in the 'Local address' space it did not work with public ip.

Thank you all for your time and for putting me on the right track.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group