Categories

Main
Database
Java
Microsoft.NET
Adabas
DB2
Informix
Microsoft SQL Server
MySQL
Oracle
Pervasive.SQL
PostgreSQL
Sybase
Other
ASP
ColdFusion
Crystal Reports
Delphi, C etc
JAVA
Microsoft.NET
Perl and the DBI
PHP
ANSI SQL
Unix Shell Scripts
Visual Basic
XML & XSLT
Corel Paradox
FileMaker
Microsoft Access
Microsoft Excel
Other PC Databases
Applications & Tools
Database Concepts & Design
EJB programming & troubleshooting
EJB design
General J2EE
XML & Web services
Web tier: servlets, JSP, Web frameworks
Performance and scalability
Industry news
TSS feedback
Mobicents Contributors
Mobicents Users
JSLEE Resource Adaptor Types
Planning JavaOne 2008
Sun Tech Days
Other Java conferences
Binary Web Services and XML
Metro and JAXB
GlassFish
GlassFish Plugins
Project jMaki
GlassFish WebTier
Mural
Java Development Tools
Java WS & XML Community News
JAXP
Java SE
6uN Early Access
Java Quick Starter
Java SE Snapshots: Project Feedback
JCK Forum
Feedback and Suggestions
JDK Distros
JDK Open Source
General JSR Discussion
JCP 2.6
JXTA Community Forum
ME Interest
ME Cool Apps
ME General Help
ME Feedback & Suggestions
ME Application Developer Interest
Blu-ray Disc Java
ME Developer Days
Squawk
Mobile Developer Alliance
OpenCable
LWUIT
JavaFX Script Language Discussion
OpenJFX General Discussion
Scene Graph
General Performance Discussion
Your Java Career
NetBeans 6.0
Servlets
JSP
JSF
Portals and Portlets
EJB and Other Java EE Technologies
Distributed Java
Object Relational Mapping
JDBC
Web Services
Swing / AWT / SWT / JFace
JNLP and Web Start
Java Micro Edition
Sockets and Internet Protocols
Threads and Synchronization
Performance
Applets
I/O and Streams
Other Java APIs
Game Development
Java in General (beginner)
Java in General (intermediate)
Java in General (advanced)
Programmer Certification (SCJP)
Developer Certification (SCJD)
Associate Certification (SCJA)
Web Component Certification (SCWCD)
EJB Certification (SCBCD)
Mobile Application Certification (SCMAD)
Architect Certification (SCEA)
Web Services Certification (SCDJWS)
XML Certification
Product and Other Certifications
Mock Exam Errata
Sun Certification Results
Authors' Corral
Book Reviews
Events
Bunkhouse Porch
Teachers' Lounge
Testing
OO, Patterns, UML and Refactoring
IDEs, Version Control and other tools
Ant, Maven and Other Build Tools
Linux / UNIX
Mac OS
HTML and JavaScript
XML and Related Technologies
Agile and Other Processes
General Computing
Security
Groovy
Scala
Other Languages
Struts
Application Frameworks
Other Open Source Projects
BEA/Weblogic
IBM/Websphere
Oracle/OAS
Apache/Tomcat
JBoss
Other Java Products and Servers
JavaRanch
Cattle Drive (java college)
Moderators Only
Trash Can
Jobs Offered
Jobs Wanted
Jobs Discussion
Meaningless Drivel
Programming Diversions
Blatant Advertising
Java Announcements
New To Java
Advanced Java
Java Applets
Networking
Threads and Synchronization
Java 2D
AWT / Swing
SWT / JFace
CLDC and MIDP
CDC and Personal Profile
Sun Java Wireless Toolkit
Enterprise JavaBeans
JavaServer Pages (JSP) and JSTL
Java Servlet
JavaServer Faces
Web Frameworks
Database
XML
Lucene
NetBeans
Eclipse
IntelliJ IDEA
JCreator
Other IDEs
Java Tutorials
Java Tips
Jobs Discussion
Jobs Offered
Jobs Wanted
Professional Certification
Forum Lobby
Java Blogs
Introductions
Reviews / Advertising
Suggestions & Feedback

Resources

Java Database
Linux
Coding
Mobile
Hardware
Software Development
Software Development
iOS,OS X
iOS,OS X
ORACLE
IBM DEVELOPER
IBM DEVELOPER
MSDN
MSDN


Tags

Distributed Java

Topics covering RMI, CORBA, Jini, Jiro, JXTA etc.

Socket timeouts for RMI


Does RMI have a timeout period within which a remote invocation must return? Can I change this timeout period programatically for a specific remote method invocation?ThanksGayatri

   
   
   
 

      Yep. There is a way.You can implement a custom RMI socket factory that sets the socket timeout to the desired value.This socket factory can be specified while exporting/creating a remote object.This tutorialtells the details to write and use a custom socket factory.You can use the below code for setting the socket timeout value.(This is not the complete code but just the createServerSocket() method of RMIServerSocketFactory. timeOutPeriod is the time out period that you would wish to set. Similarly you can write a client socket factory for client rmi sockets)code:public ServerSocket createServerSocket(int port) throws IOException {ServerSocket socket = RMISocketFactory.getDefaultSocketFactory().createServerSocket(port);socket.setSoTimeout(timeOutPeriod);return socket;}--------------------You are never alone in a ditch, its just that the ditch is too big! Just$#%&GoogleIt

   
   

 
   
      Thanks . I tried it. But dont know what the actual problem is. I created the custom socket and set the timout to 5 sec. Now if there is no response from server for 5 sec, client should time out. But it does nothere is my code:  any hints what is going wrong ?public static void main(String[] args)throws EncException,Exception {...RMISocketFactory.setSocketFactory(new TimeoutFactory(5));Object obj = stub.remotemethod();// If no response from server for 5 sec, it should time out, but it does not.}class TimeoutFactory extends RMISocketFactory {private int timeout;public TimeoutFactory(int timeout) {this.timeout = timeout;}public Socket createSocket(String host, int port) throws IOException {Socket ret = getDefaultSocketFactory().createSocket(host, port);System.out.println("timeout set");ret.setSoTimeout(timeout * 1000);return ret;}public ServerSocket createServerSocket(int port) throws IOException {return getDefaultSocketFactory().createServerSocket(port);}}Am i placing the code for setting timeout at wrong place ?ThanksGayatri

   
   
   
 

      The code you have specified should work provided:You set the socket factory before looking up the stub.The server object while getting exported does not define a client socket factory.--------------------You are never alone in a ditch, its just that the ditch is too big! Just$#%&GoogleIt


Related Links

CORBA.NO_PERMISSION
Multicast Error on Win Xp service Pack 2(Urgent)
Can we make RMI transport additional implicit objects?
JXTA anyone?
Can we call RMI tghrough C++
Transfer files between different OSs
Java RMI
getting ConnectException
Java RMI
how to set JacOrb connection time out
how to maintain data in distributed environment
starting jms
rmi over JRMP deprecated?
rmi-iiop help
RMI - strange lease signals
accessing files on a remote server from a web application