Solved

Not able to connect to server in RMI Java

Posted on 2013-05-22
7
1,032 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
xampp tool 12 47
Running JavaFX on JDeveloper 12C 1 31
pagenation logic how it is working in my code 1 26
JAVA API design with micro service cloud in mind 1 10
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
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.
The viewer will learn how to implement Singleton Design Pattern in Java.
This video teaches viewers about errors in exception handling.

815 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

7 Experts available now in Live!

Get 1:1 Help Now