Solved

Not able to connect to server in RMI Java

Posted on 2013-05-22
7
1,078 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
Plug and play, no additional software required!

The ATEN UE3310 USB3.1 Gen1 Extender Cable allows users to extend the distance between the computer and USB devices up to 10 m (33 ft). The UE3310 is a high-quality, cost-effective solution for professional environments such as hospitals, factories and business facilities.

 

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

628 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