Solved

Not able to connect to server in RMI Java

Posted on 2013-05-22
7
1,006 Views
Last Modified: 2013-06-05
Hi,

I am facing a weird issue in my application Java RMI server client application.

Our application is in Java and using RMI. Server has two clients and we have quite a common code for these components.

Now, issue is that connection between client1 ables to connects to server on every machine and on all java versions.

But client2 ables to connect to server most of the time but not all. Client2 is not able to connect to server at our customer end and on their four machines but client1 is connecting to server without any issue there.

We are using following common code for both clients.

String url = String.format("//%s:%d/%s", serverName, portNumber, objectLookupName);
Remote rem = Naming.lookup(url);

After adding both values, url string becomes

url ="//localhost:8320/TrackerServer

in boths case. Above server name, port and objectlookupname is same in both clients. I tried putting 127.0.0.1, localhost etc but nothing works. Even I put different versions of JDK and JRE but nothing works. Client2 works without any issue in our in house computers but no on customer site.

But in case of client1, Naming.lookup(url); returns immediately where for client2, it waits quite a long in this function. It clicked on paused in netbeans and found that it is waiting at SocketInputStream.socketread() and then it throws the following exception.

May 22, 2013 11:17:33 PM ipa.printexpress.common.helpers.rmi.RMIHelper getObject
SEVERE: null
java.rmi.ConnectIOException: Exception creating connection to: 127.0.0.1; nested exception is:
        java.net.SocketException: Malformed reply from SOCKS server
        at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:632)
        at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216)
        at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)
        at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:340)
        at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
        at java.rmi.Naming.lookup(Naming.java:101)
        at ipa.printexpress.common.helpers.rmi.RMIHelper.getObject(RMIHelper.java:128)
        at ipa.px.tracker.trackermanager.helpers.SessionHelper.initialiseSession(SessionHelper.java:42)
        at ipa.px.tracker.trackermanager.proxy.ConnectionProxy.getNewTrackerManagerIf(ConnectionProxy.java:519)
        at ipa.px.tracker.trackermanager.proxy.ConnectionProxy.checkConnection(ConnectionProxy.java:549)
        at ipa.px.tracker.trackermanager.proxy.ConnectionProxy.getInstance(ConnectionProxy.java:229)
        at ipa.px.tracker.trackermanager.proxy.ConnectionProxy.pingTrackerServer(ConnectionProxy.java:243)
        at ipa.px.tracker.trackermanager.tasks.ConnectionMonitorTask.doInBackground(ConnectionMonitorTask.java:112)
        at org.jdesktop.swingworker.SwingWorker$1.call(Unknown Source)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
        at java.util.concurrent.FutureTask.run(FutureTask.java:166)
        at org.jdesktop.swingworker.SwingWorker.run(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:722)
Caused by: java.net.SocketException: Malformed reply from SOCKS server
        at java.net.SocksSocketImpl.readSocksReply(SocksSocketImpl.java:128)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:459)
        at java.net.Socket.connect(Socket.java:579)
        at java.net.Socket.connect(Socket.java:528)
        at java.net.Socket.<init>(Socket.java:425)
        at java.net.Socket.<init>(Socket.java:208)
        at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:40)
        at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:146)
        at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)
        ... 19 more



I spent lots of time on this but could not find how to resolve it. I think issue may be in RMI registry but can't say anything.

Any help would be highly appreciated.

Cheers
0
Comment
Question by:IPA_tech
  • 4
  • 3
7 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 39188038
url ="//localhost:8320/TrackerServer

Open in new window


Client2 is not able to connect to server at our customer end
How could they if they're using the url above? (unless of course they are also running a server on localhost)
0
 

Author Comment

by:IPA_tech
ID: 39188882
Thanks for reply CEHJ

We are trying to find the reason. Earlier they were running on different machines unsuccessfully. So, we are running all three on same machine now just to find the reason, thats why localhost.

I hope it will help to find the reason and solution

Cheers
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 39188966
java.rmi.ConnectIOException: Exception creating connection to: 127.0.0.1; nested exception is:
        java.net.SocketException: Malformed reply from SOCKS server

Open in new window


Does that box use a socks proxy? If so, are the Socks Java networking properties set in the environment?

http://docs.oracle.com/javase/6/docs/technotes/guides/net/properties.html
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:IPA_tech
ID: 39190174
I dont know if that box socks proxy or not. How to find if it uses? Also, then how client1 ables to connect and client2 not.

Could you pls tell me which exact properties from this link I need to set and how?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 39190197
I dont know if that box socks proxy or not. How to find if it uses?
Ask the people who configured it or the network

Could you pls tell me which exact properties from this link I need to set and how?
"SOCKS protocol support settings"
Are the ones i had in mind
0
 

Accepted Solution

by:
IPA_tech earned 0 total points
ID: 39210372
Thanks guys for answering the my query. This issue has been fixed. The reason is

Our customer reinstalled the OS and then reinstalled our software, it fixed the issue.

I will marked this as an accepted solution.
0
 

Author Closing Comment

by:IPA_tech
ID: 39221460
Reinstalling OS and software fixed the issue.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now