Solved

Not able to connect to server in RMI Java

Posted on 2013-05-22
7
1,015 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JavaScript/Java - Changing an image background color 4 56
rhino JavaScript import, load 25 67
couple of eclipse 5 23
factorial example 4 35
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This is about my first experience with programming Arduino.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

920 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

12 Experts available now in Live!

Get 1:1 Help Now