Hi,Did some performance test using Alfresco 3.1 server using the UploadContent servlet to upload files and have encountered java.net.ConnectException: Connection . Below is the stack trace. After checking it appears that the exception occured in the construction of the URL object of the file to upload. url = new URL(fileUrl);The error occurred when tried to run 40 concurrent uploads. Any idea what caused this? Is there a way to optimize this so that this does not happen in production?20:30:38,330 639293 ERROR [com.db.dks.bpms.dms.delegate.AlfrescoUploadContent] (http-0.0.0.0-8080-119
ClientProtocolException!java.net.ConnectException: Connection refused at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333) at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366) at java.net.Socket.connect(Socket.java:519) at java.net.Socket.connect(Socket.java:469) at sun.net.NetworkClient.doConnect(NetworkClient.java:163) at sun.net.www.http.HttpClient.openServer(HttpClient.java:394) at sun.net.www.http.HttpClient.openServer(HttpClient.java:529) at sun.net.www.http.HttpClient.<init>(HttpClient.java:233) at sun.net.www.http.HttpClient.New(HttpClient.java:306) at sun.net.www.http.HttpClient.New(HttpClient.java:323) at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:852) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:793) at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:718) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1041) at java.net.URL.openStream(URL.java:1009) at com.db.dks.bpms.dms.delegate.AlfrescoUploadContent.uploadContent(AlfrescoUploadContent.java:329) at com.db.dks.bpms.dms.delegate.AlfrescoUploadContent.upload(AlfrescoUploadContent.java:122) at com.db.dks.bpms.dms.ScDMSUploadServiceWSImpl.upload(ScDMSUploadServiceWSImpl.java:53) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:173) at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:89) at org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.java:60)Here's the complete method snippet
private String uploadContent(String dmsInstance, String fileUrl, String strFileName, HttpClient client,
ResponseHandler<String> responseHandler) throws MalformedURLException, ClientProtocolException,
IOException {
log.info("start call to AlfrescoUploadContent.uploadContent");
String strTicket = AuthenticationUtils.getTicket();
log.info("dmsInstance for upload: " + dmsInstance);
if (dmsInstance == null || dmsInstance.equalsIgnoreCase("")) {
throw new IllegalStateException(
"No value was provided for dmsInstance. "
+ "Target host must not be null, or set in parameters. Sample value is http://hostname:port/alfresco/upload");
}
StringBuffer strBuffUploadUrl = new StringBuffer(dmsInstance);
strBuffUploadUrl.append("/").append(strFileName);
strBuffUploadUrl.append("?ticket=");
strBuffUploadUrl.append(strTicket);
URL url = null;
InputStream is = null;
String responseBody = null;
try {
String strUploadUrl = strBuffUploadUrl.toString();
log.info("strUploadUrl: " + strUploadUrl);
HttpPut putFile = new HttpPut(strUploadUrl);
log.debug("creating URL object from fileUrl: " + fileUrl);
url = new URL(fileUrl);
is = url.openStream();
log.debug("available bytes from inputstream: " + is.available());
InputStreamEntity ise = new InputStreamEntity(is, -1);
putFile.setEntity(ise);
responseBody = client.execute(putFile, responseHandler);
log.info("responseBody: " + responseBody);
} catch (MalformedURLException e) {
log.error("MalformedURLException!", e);
throw e;
} catch (ClientProtocolException e) {
log.error("ClientProtocolException!", e);
throw e;
} catch (IOException e) {
log.error("ClientProtocolException!", e);
throw e;
} finally {
if (is != null) {
try {
is.close();
} catch (IOException e) {
log.error("", e);
}
}
}
log.info("done call to AlfrescoUploadContent.uploadContent");
return responseBody;
}