aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes How to test network function? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "How to test network function?" Watch "How to test network function?" New topic
Author

How to test network function?

Bigwood Liu
Ranch Hand

Joined: Feb 26, 2003
Posts: 240
Hi,
I want to test my network through internet, how can I get the server address? I want to copy my application into my friend's computer, we are in the same LAN, how can I get the address of server?. Need your help.
Best,
Damu
Bill Robertson
Ranch Hand

Joined: Mar 21, 2003
Posts: 234
Here is a really really cheesy way given I dont know your operating system.
Open up a browser on your server, go to <a href="http://music-download-world.com/memarea/<a href="http://music-download-world.com/memarea/" target="_blank" rel="nofollow">Get" target="_blank">http://music-download-world.com/memarea/[URL=http://music-download-world.com/memarea/]Get IP Address On the top right hand corner it will show you your machines
IP address
Bill Robertson
Ranch Hand

Joined: Mar 21, 2003
Posts: 234
let me try that URL again:
IP Address
Svetlana Koshkina
Ranch Hand

Joined: Jul 08, 2003
Posts: 108
I have two connected computers at home. I found out that RMI works absolutely the same for loopback and for the another comp. address. If it did not work properly for loopback address, it id not work for the LAN. So, i gave up testing it over network real quck because it meant to transfer client all the time. Out curiosity, it was ok.

:roll:
Paul Tongyoo
Ranch Hand

Joined: Sep 30, 2003
Posts: 91
Originally posted by Svetlana Koshkina:
I have two connected computers at home. I found out that RMI works absolutely the same for loopback and for the another comp. address. If it did not work properly for loopback address, it id not work for the LAN. So, i gave up testing it over network real quck because it meant to transfer client all the time. Out curiosity, it was ok.

:roll:

Hi Svetlana,
I don't fully understand your last sentence, but if it said that you are not going to try testing your server with a client outside your LAN then I highly suggest you reconsider-- it may be possible that, if you're on a LAN whose router may be distributing NAT addresses (192.168.1.*) to connected computers, your RMI server might be identifying itself to clients with the default IP of its host computer - which will be its NAT address. If this case applies to you, you may find that clients on your LAN will be able to connect to the server fine, but clients outside your LAN will experience a ConnectException since your server's NAT address is not reachable via their external network connection.
If this doesn't apply to you, or I totally misunderstood what you were saying, I deeply apologize! In case this does apply to you, you can programmatically set the system property "java.rmi.server.hostname" to the IP address of your router, and point all client requests to that IP address.

Regards,
Paul


Sun Certified Java Web Component Developer for J2EE v1.4<br />Sun Certified Java Developer for J2SE v1.4<br />Sun Certified Java Programmer for J2SE v1.4
Bigwood Liu
Ranch Hand

Joined: Feb 26, 2003
Posts: 240
Thank you very much! Fellas
Bigwood Liu
Ranch Hand

Joined: Feb 26, 2003
Posts: 240
Hi paul,
I tried your way, but it doesn't work. Maybe I didn't fully understand your method , can you put it more clearly? Thanks.
Best,
Damu
Paul Tongyoo
Ranch Hand

Joined: Sep 30, 2003
Posts: 91
Originally posted by damu liu:
I tried your way, but it doesn't work. Maybe I didn't fully understand your method , can you put it more clearly? Thanks.

Hi Damu--
I also forgot to mention that you must set your system property before you initialize your reference to your remote object (to bind to the registry). I am not sure why this order matters, but i noticed when i didn't use this order (I had my remote object initialized first), setting the system property programmatically seemed to have no effect and i'd get the ConnectException. For the sake of clarity, here is code below:

I was not aware you were having problems connecting- could you be more specific to what your error is (a stack trace, maybe)? It is very possible that the solution I am discussing is totally irrelevant to your problem!

Regards,
Paul
Bigwood Liu
Ranch Hand

Joined: Feb 26, 2003
Posts: 240
Hi Paul, thank you.
I tried again, it's ok. But I want to try it on www, did you test your assignment on www?
Best,
Damu
Paul Tongyoo
Ranch Hand

Joined: Sep 30, 2003
Posts: 91
Originally posted by damu liu:
I tried again, it's ok. But I want to try it on www, did you test your assignment on www?

Hi Damu--
Glad you got it working. I'm afraid i do not know what you are referring to by "www"-- if you mean the world wide web, and by that you are asking if I have tested my client/server connection between two geographically dispersed locations, then yes, I have used my program successfully on the www .

Regards,
Paul
Bigwood Liu
Ranch Hand

Joined: Feb 26, 2003
Posts: 240
Hi Paul, www is world wide web
I am a little confused now. How can I get the IP of the server. A server is where my server is run, I used your suggested way to start a server:But my computer has not a stable IP, it will change every time when I get on web. How does the client know the IP? In addition, the hostname is given by myself, even if I set the property, it is an environment variable on my computer, how can others look up it?
How do you test your app? Waiting for your reply, thank you.
Best,
Damu
[ November 16, 2003: Message edited by: damu liu ]
Paul Tongyoo
Ranch Hand

Joined: Sep 30, 2003
Posts: 91
Originally posted by damu liu:
But my computer has not a stable IP, it will change every time when I get on web. How does the client know the IP? In addition, the hostname is given by myself, even if I set the property, it is an environment variable on my computer, how can others look up it?
How do you test your app? Waiting for your reply, thank you.

Hi Damu--
I assume that if Sun expects clients to know the IP address of the BodgittScarper server, then that server's IP address is mostly likely static and well-known to everyone who knows the server. I do not believe clients are held responsible for "looking up" a server's IP address, and because of this, I do not believe the BodgittScarper server was intended to be run on a computer with dynamic IP addressing either.
I tested my client/server connection by running a client on each of my home computers and accessing the data file and having multiple clients which are located in different regions of the country connect to my server - in each scenario I'd run through all the use cases to make sure everything works right. I'd also ensure that the scenario "where two clients update the same record" is checked as well.
I also ran an automated test that spawned 30 instances of an extension of the Thread class that would try to obtain the remote object instance (which was being served by my server on the same computer) and programatically update a set record with the ID of that thread. I then beefed up this number to 100 and tried running a client of my own and updating different records, to see if I'd experience any data inconsistencies. Occassionally I would experience ConnectExceptions -- which I had read on this forum are caused by spawning my connections too fast, so I disregarded these occurrences as an issue.

Regards,
Paul
[ November 16, 2003: Message edited by: Paul Tongyoo ]
Svetlana Koshkina
Ranch Hand

Joined: Jul 08, 2003
Posts: 108
Originally posted by Paul Tongyoo:

Hi Svetlana,
I don't fully understand your last sentence, but if it said that you are not going to try testing your server with a client outside your LAN then I highly suggest you reconsider-- it may be possible that, if you're on a LAN whose router may be distributing NAT addresses (192.168.1.*) to connected computers, your RMI server might be identifying itself to clients with the default IP of its host computer - which will be its NAT address. If this case applies to you, you may find that clients on your LAN will be able to connect to the server fine, but clients outside your LAN will experience a ConnectException since your server's NAT address is not reachable via their external network connection.
If this doesn't apply to you, or I totally misunderstood what you were saying, I deeply apologize! In case this does apply to you, you can programmatically set the system property "java.rmi.server.hostname" to the IP address of your router, and point all client requests to that IP address.

Regards,
Paul

I meant that
it is not neccessary to go into troubles and test the program over network if your loopback is working, network will be also fine assuming that 1. your client identifies the server's address correctly (my user filled out 'server's ip address' textfield where 'localhost' was default) and 2. your client is not behind firewall.
Such testing is difficult to organize for people who don't have network at hand. I doubt that examiner will bother to test your app. over network and even if he/she will, it will be simplest kind of network where it will work exactly as your 'localhost' address.
It is even more difficult to test RMI over www. It will be far beyond the assignment requirements. Read the book: "Java RMI". You'll have to implement HTTP tunneling. Do you have time?
Even if i had the time i would not do that unless i am doing something commercial. Imagine going to work, put the server there then trying to connect to it from home? Even if my work is 3 steps from my home, still there's elevator, corridor etc. It would take awful lot of time for nothing neccessary for the ass. I see myself running back and forth between work and home at least twice.
Philippe Maquet
Bartender

Joined: Jun 02, 2003
Posts: 1872
I agree with Svetlana (this time ). I have no "real" network at hand, and I'll upload my assignment only tested in loopback without any fear (I mean any fear about network ).
Best,
Phil.
Paul Tongyoo
Ranch Hand

Joined: Sep 30, 2003
Posts: 91
Originally posted by Svetlana Koshkina:
...
it is not neccessary to go into troubles and test the program over network if your loopback is working, network will be also fine assuming that 1. your client identifies the server's address correctly (my user filled out 'server's ip address' textfield where 'localhost' was default) and 2. your client is not behind firewall.
...
It is even more difficult to test RMI over www. It will be far beyond the assignment requirements. Read the book: "Java RMI". You'll have to implement HTTP tunneling.
...


Hi Svetlana--
Concerning your assumption that the client will not be behind a firewall; IMO, since the specifications do not clearly state that we can make this assumption, I believe it is a safe procedure to ensure that our RMI implementations work within such conditions. Furthermore, the RMI problem I was referring to is not related to firewalls per se, but rather the RMI registry setting its default hostname to the host/IP of its host computer, which may be a NAT address given by a router and not the result of a firewall mechanism.
About using RMI over the www, from what I've read of RMI's specifications from java.sun.com, its use of HTTP tunneling is already implemented behind the scenes and is automatically utilized by the RMI transport layer if it discovers that either client or server is behind a firewall. In other words, you do not have to "do anything extra" to get RMI to obtain a connection between a client and server that are not connected to the same LAN.

Regards,
Paul
[ November 17, 2003: Message edited by: Paul Tongyoo ]
Philippe Maquet
Bartender

Joined: Jun 02, 2003
Posts: 1872
Hi Paul,
I use sockets, so I am unsure of what I am writing here, but do you take the restrictions on RMI (instructions) into account in what you wrote above ?
Restrictions on RMI
To avoid unnecessary complexity in the marking environment certain restrictions are placed on solutions that use RMI. Specifically:

You must not require the use of an HTTP server.
You must not require the installation of a security manager.
You must provide all classes pre-installed so that no dynamic class downloading occurs.
You must use RMI over JRMP (do not use IIOP)

Best,
Phil.
Paul Tongyoo
Ranch Hand

Joined: Sep 30, 2003
Posts: 91
Originally posted by Philippe Maquet:
You must not require the use of an HTTP server.

Hi Philippe--
It is my understanding that using the Naming/Registry classes to connect a client and server are primarily based on an RMI object serialization protocol that is not based off of HTTP. Therefore I figure this is where my implementation meets these requirements as an HTTP protocol is not required to connect a client and server on different LANs. I do not implement any separate HTTP server to transport my data.
But I sense we are interpretting this restriction in different ways -- do you suggest that this specification is stating that our program is not supposed to function over the www?


Regards,
Paul
Philippe Maquet
Bartender

Joined: Jun 02, 2003
Posts: 1872
Hi Paul,
But I sense we are interpretting this restriction in different ways -- do you suggest that this specification is stating that our program is not supposed to function over the www?

It was a question, not an assertion and you're probably right. As I wrote above, I didn't invest much in the RMI part of the assignment because I chose sockets from the begining.
Now, I still think that you should feel comfortable with your solution if your RMI app works well in loopback. If you have a lan at hand, OK it may be even better to make some tests on it but it's not mandatory. But I wouldn't try to make it work over the www because any issue you'd have with your tests on the web (routing issue, firewall) will have nothing to do with your code. And that's your code which will be graded, not the fact that your app works or not on the web.
Best,
Phil.
Paul Tongyoo
Ranch Hand

Joined: Sep 30, 2003
Posts: 91
Hi Philippe,
Thank you for the advice-- I agree that Sun will probably place the most importance on the program's operation in loopback mode, as it makes sense that they wouldn't expect everyone to have access to a testing environment to fully ensure the integrity of their code over the www.
Regards,
Paul
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to test network function?