We are implementing xmlrpc client where HTTP 1.1 is implemented at server end. Server end is with another company and we can not change it. As HTTP 1.1 RFC Server send us Connection header without Keep-Alive and xmlrpc client should not close it because that's the default behavior standardize in http 1.1. However My client xmlrpc implementation closes the connection after one request and then open new connection for next request, i tried with my own server and forcing server to send me keep-Alive, then xmlrpc client honors the keep-alive and keep the connection open for multiple requests. But as per HTTP 1.1 its not the expected behavior.
I investigated that xmlrpc client relies on different factories and sun15 factory is being used and xmlrpc relies on this factory, but i am still unable to identify why sun15 factory does not honors the standard. Maximum requests I saw on a single connection are 3 then client send TCP FIN to server to close the connection.
Below is my code for client ** **XMLRPC Client **
`package com.example;
import org.apache.xmlrpc.XmlRpcClient;
import java.util.Scanner;
import java.util.Vector;
public class MultithreadingClient extends Thread {
public void run() {
try {
XmlRpcClient client = new XmlRpcClient("http://localhost:5300/");
Vector params = new Vector();
String msg = "hi";//sc.nextLine();
params.addElement(msg);
// Send message to server with method name
Object result = client.execute("myServer.getMessage", params);
params.clear();
System.out.println("Thread "+Thread.currentThread().getId()+" : "+result);
} catch (Exception exception) {
System.err.println("JavaClient: " + exception);
}
}
}
`
**main class **
`package com.example;
public class xmlrpcClient {
public static void main(String []args) throws InterruptedException {
int n = 50; // Number of threads
for (int j = 0; j < 50; j++) {
for (int i = 0; i < 5; i++) {
MultithreadingClient thread = new MultithreadingClient();
thread.start();
}
Thread.sleep(5000);
}
}
}`