• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Major problems with networking client.

 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Firstly I'm just running project locally.
I'm having major issues with networking client. I have the GUI set-up correctly.
First thing I'm finding is that when I input the client ip address, the method getByAddress(address) from the "java.net.InetAddress" package will return the valid TCP connections that exist. So for example:
I input 0.0.0.0 and tcp connection already exists on machine, this will return as valid.
Same if I input 127.0.0.1, this will return as valid, so if the server is running as 127.0.0.1, and client tries to connect using 0.0.0.0, the application currently crashes.
Is 1 suppose to write the server ip address and port in the shared configuration file?
If so, how does 1 obtain the server ip address in rmi when binding the remote object?
I'm questioning this, because if multiple say 127.0.0.1 and multiple 0.0.0.0 tcp connections already exist, they will be seen as obtaining valid addresses by the method getByAddress(address).

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I do a ping to check if the IP is correct. Like this:
 
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy, Mark!

Champion, I'm not really sure if I got your question... but, from the server perspective, you should only have to write the database location in the configuration file. The client that wants to connect to it must have the server IP address and port number in which the service is running before connecting to it.
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark, have you try outputting that ip address on the server - InetAddress.getHostAddress() or something? It should not be 127.0.0.1 but 192.168.x.x for LAN.

Also if you entered 127.0.0.1 on the client to connect to the server then it WILL ONLY connect to 127.0.0.1 and not localhost. Same for the other way. If you use host name to connect (eg localhost) then entering the IP will not work.

I recommend you use the ip version because changing servers is simpler.
 
Mark O' Sullivan
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I will update the problem I'm facing here. Any help very much appreciated.
Firstly I am running both client and server on same machine, and using port 1099.
Here is code I use to register the HotelReservationImpl object:

and here is code I use to look up object:

Using the following code to resolve the hostname to ip address and storing as string:

I presume this is ok.
So therefore the System.out.println, when I try and look up object results in;
The system.out.println is printing “The host name is localhost/127.0.0.1 the port number is 1099”
I presume this is ok.
But I'm getting a bound exception, clearly "Naming.lookup" isn't working.
"HotelReservator not bound: null"
I thought It might be the fact I haven't generated the HotelReservationImpl stub but I have, maybe it can't find it, using eclipse by the way. I know it should automatically but I did again just in case.
I wonder could it be an issue with the way the database is stored in properties file, I'm using windows:
I think this is ok, entry is saved when server starts as DatabaseLocated=D\:\\eclipseProjects\\MarksProjects\\db-1x2.db
Localhost is 127.0.0.1. I have also included the server images before and after it starting.
Any help must appreciated.







finalRMIImage.JPG
[Thumbnail for finalRMIImage.JPG]
 
K. Tsang
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark,

If Naming.lookup() isn't working try using LocateRegistry.getRegistry(address, port).

Also depending on how you bind your server, the hostname or ip must match on the client.
 
My name is Inigo Montoya, you killed my father, prepare to read a tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic