Discussions
Categories
- 196.8K All Categories
- 2.2K Data
- 239 Big Data Appliance
- 1.9K Data Science
- 450.3K Databases
- 221.7K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 31 Multilingual Engine
- 550 MySQL Community Space
- 478 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3K ORDS, SODA & JSON in the Database
- 544 SQLcl
- 4K SQL Developer Data Modeler
- 187K SQL & PL/SQL
- 21.3K SQL Developer
- 295.9K Development
- 17 Developer Projects
- 138 Programming Languages
- 292.5K Development Tools
- 107 DevOps
- 3.1K QA/Testing
- 646K Java
- 28 Java Learning Subscription
- 37K Database Connectivity
- 155 Java Community Process
- 105 Java 25
- 22.1K Java APIs
- 138.1K Java Development Tools
- 165.3K Java EE (Java Enterprise Edition)
- 18 Java Essentials
- 160 Java 8 Questions
- 86K Java Programming
- 80 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 204 Java User Groups
- 24 JavaScript - Nashorn
- Programs
- 439 LiveLabs
- 38 Workshops
- 10.2K Software
- 6.7K Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 171 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 232 Portuguese
Too many sockets with custom socket factory implementation with JSSE

Hello,
I've implemented custom socket factory as defined in the JSSE example here: https://docs.oracle.com/javase/10/security/sample-code-illustrating-secure-rmi-connection.htm#JSSEC-GUID-2F82CCFD-22E6-4E6E-A2E1-88CF2BB19E87
When I run my applications, rmi works fine along with ssl. But, what I noticed is that too many threads/ sockets are created. Socket reuse is not happening. When looking for this problem, found out this page: https://docs.oracle.com/javase/7/docs/technotes/guides/rmi/faq.html#customsocketreuse (look for A.5), which expresses the problem with too many socket creation when using custom socket factories. When tried to override the equal and hashcode of custom socket factories, the looking up of remote object in the registry fails during unmarshalling phase. It throws an exception about the serialVersionUID of the custom client socket factory being different from the local class as below.
java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.io.InvalidClassException: ...SslClientSocketFactory; local class incompatible: stream classdesc serialVersionUID = -2466850771396148787, local class serialVersionUID = -8809708706764478887
Defining a static serialVersionUID for SslClientSocketFactory also doesn't work. Throws the same exception. The problem can be that RMI runtime internally uses RMIClientSocketFactory
for getting the rmi clients for RMI calls and has a different serialVersionUID for the client socket factory.
Has anyone faced a similar problem and have a solution for this?