Solved

Not able to connect to server in RMI Java

Posted on 2013-05-22
7
1,060 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Simple, centralized multimedia control

Watch and learn to see how ATEN provided an easy and effective way for three jointly-owned pubs to control the 60 televisions located across their three venues utilizing the ATEN Control System, Modular Matrix Switch and HDBaseT extenders.

Question has a verified solution.

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

Suggested Solutions

This is about my first experience with programming Arduino.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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:
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Suggested Courses

738 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