[
https://issues.apache.org/jira/browse/AXIS2-2593?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12496414
]
David Bueche commented on AXIS2-2593:
-------------------------------------
Also, here is the code used to invoke the service, mostly incorporated from the
test case, but using JiBX stub generated from WSDL2Java and with comments
identifying other divergences from the test case code:
private void sendRecords(List<MyRecord> records)
throws RemoteException, SubscriptionException,
IOException {
logger.debug("Publishing to consumer at: " + this.consumerUrl
+ "; clientId = " + this.clientId + "; sending
records: "
+ records);
MyRecord[] recordArray = new MyRecord[records.size()];
records.toArray(recordArray);
this.verifyStub();
boolean success = this.stub.performService(recordArray);
if (!success) {
throw new SubscriptionException(
"stub.performService(recordArray)
Failed");
}
}
// note that only one thread will ever have control at a time, thus no
need
// for synchronize
private void verifyStub() throws AxisFault {
if (this.stub == null) {
ConfigurationContext context =
getConfigurationContext();
this.stub = new MyRecordConsumerStub(context,
this.consumerUrl);
//
this.stub._getServiceClient().setCachingOperationContext(true); // previously,
but no longer used
Options options =
this.stub._getServiceClient().getOptions(); // Options retrieved from stub
instead of created new
// endpoint is already set, so no need to reset it in
the options below:
// EndpointReference targetEPR = new
EndpointReference(this.consumerUrl);
// options.setTo(targetEPR);
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
// this was resulting in WS-Addressing module AxisFault
before fixing addressing module issue
options.setUseSeparateListener(true);
// this is replaced by an explicit assignment for now
// options.setAction(operationName.getLocalPart());
// don't think I need this -- breaks with or without --
options.setAction("performService");
options.setTimeOutInMilliSeconds(TIMEOUT);
options.setProperty(HTTPConstants.CHUNKED,
Boolean.TRUE);
options.setProperty(HTTPConstants.SO_TIMEOUT, TIMEOUT);
options.setProperty(HTTPConstants.CONNECTION_TIMEOUT,
TIMEOUT);
// this results in no repeat calls working
options.setProperty(HTTPConstants.REUSE_HTTP_CLIENT,
Boolean.TRUE);
// this results in reading from a closed stream
options.setProperty(HTTPConstants.AUTO_RELEASE_CONNECTION, Boolean.TRUE);
}
}
// Since this method initializes static variables, it must be
synchronized
private synchronized ConfigurationContext getConfigurationContext()
throws AxisFault {
if (configurationContext == null) {
MultiThreadedHttpConnectionManager connectionManager =
new MultiThreadedHttpConnectionManager();
HttpConnectionManagerParams connectionManagerParams =
new HttpConnectionManagerParams();
connectionManagerParams.setDefaultMaxConnectionsPerHost(1);
connectionManagerParams.setTcpNoDelay(true);
connectionManagerParams.setStaleCheckingEnabled(true);
connectionManagerParams.setLinger(0); // not previously
used
connectionManager.setParams(connectionManagerParams);
HttpClient httpClient = new
HttpClient(connectionManager);
configurationContext =
createClientConfigurationContext();
// configurationContext.setThreadPool(new ThreadPool(1,
3));
configurationContext.setThreadPool(new
ThreadPool(10000, 10000)); // not previously used
configurationContext.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Boolean.TRUE);
configurationContext.setProperty(HTTPConstants.CACHED_HTTP_CLIENT, httpClient);
}
return configurationContext;
}
public static ConfigurationContext createClientConfigurationContext()
throws AxisFault {
File file = getAddressingMARFile();
TestCase.assertTrue(file.exists());
ConfigurationContext configContext = ConfigurationContextFactory
.createConfigurationContextFromFileSystem(
//
"target/test-resources/integrationRepo",
//
"target/test-resources/integrationRepo/conf/axis2.xml");
"C:\\axis2-SNAPSHOT\\repository",
"C:\\axis2-SNAPSHOT\\conf\\axis2.xml");
AxisModule axisModule = DeploymentEngine.buildModule(file,
configContext.getAxisConfiguration());
configContext.getAxisConfiguration().addModule(axisModule);
return configContext;
}
static class AddressingFilter implements FilenameFilter {
public boolean accept(File dir, String name) {
return name.startsWith("addressing") &&
name.endsWith(".mar");
}
}
private static File getAddressingMARFile() {
File dir = new File("C://axis2-SNAPSHOT//repository//modules");
File[] files = dir.listFiles(new AddressingFilter());
TestCase.assertTrue(files.length == 1);
File file = files[0];
TestCase.assertTrue(file.exists());
return file;
}
> Web Service request loop causes many TIME_WAIT Connections & "BindException:
> Address already in use: connect"
> -------------------------------------------------------------------------------------------------------------
>
> Key: AXIS2-2593
> URL: https://issues.apache.org/jira/browse/AXIS2-2593
> Project: Axis 2.0 (Axis2)
> Issue Type: Bug
> Affects Versions: 1.1.1, nightly
> Environment: Windows XP, Tomcat, Axis2 nightly build (also
> encountered in 1.1.1), JiBX 1.1.3, Microsoft Windows XP [Version 5.1.2600],
> 126 GB free disk space, 1GB RAM.
> Reporter: David Bueche
> Priority: Critical
> Attachments: diff.txt, JIRA-935_2593.zip, JIRA_test.tar.gz
>
>
> I am performing the following:
> - Executing a tight loop calling a singel web service
> - Using the same Stub over and over
> - Creating the Stub with a custom ConfigurationContext (see below)
> - Sending cleanup() to Stub after each message sent (although problem existed
> even before cleanup() was added)
> After approximately 4000 messages have been sent, an AxisFault is generated
> caused by the following exception (see below for full stack trace):
> java.net.BindException: Address already in use: connect
> It appears that connections from the client to Axis on Tomcat sometimes (but
> not always) remain in the TIME_WAIT state for several minutes. There are
> 1200-1500 TIME_WAIT connections open when the AxisFault is generated.
> If I step through the web service messages in a debugger, the problem does
> not appear to occur, as the system eventually releases the connections after
> a minute or two.
> Also, if I insert a System.gc() in the client code each time it sends a
> message to the web service (the commented out line of code below), the
> AxisFault does not occur. I have executed the loop over 60,000 times with
> the garbage collection included without generating an AxisFault. There were
> only 400-700 connections in the TIME_WAIT state at a given time, but
> performance slowed down to a crawl.
> Here is the code I am using to create the Stub:
> HttpConnectionManagerParams connectionManagerParams = new
> HttpConnectionManagerParams();
> connectionManagerParams.setTcpNoDelay(true);
> connectionManagerParams.setStaleCheckingEnabled(true);
>
> MultiThreadedHttpConnectionManager connectionManager = new
> MultiThreadedHttpConnectionManager();
> connectionManager.setParams(connectionManagerParams);
> HttpClient httpClient = new HttpClient(connectionManager);
>
> ConfigurationContext configurationContext =
> ConfigurationContextFactory.createConfigurationContextFromFileSystem(null,
> null);
> configurationContext.setProperty(HTTPConstants.REUSE_HTTP_CLIENT,
> Boolean.TRUE);
> configurationContext.setProperty(HTTPConstants.CACHED_HTTP_CLIENT,
> httpClient);
>
> stub = new MyServiceStub(configurationContext, target);
>
> boolean success = true;
> while(success) {
> success = stub.performService(records);
> stub.cleanup();
> // System.gc();
> }
> Here is the complete stack trace:
> Exception in thread "main" org.apache.axis2.AxisFault: Address already
> in use: connect
> at org.apache.axis2.AxisFault.makeFault(AxisFault.java:377)
> at
> org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:179)
> at
> org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:73)
> at
> org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:310)
> at
> org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:202)
> at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:446)
> at
> org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:330)
> at
> org.apache.axis2.description.OutInAxisOperationClient.execute(OutInAxisOperation.java:294)
> at
> com.ws.service.MyServiceStub.performService(MyServiceStub.java:300)
> at com.ws.client.MyClient.main(MyClient.java:88)
> Caused by: java.net.BindException: Address already in use: connect
> 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 sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
> at
> org.apache.commons.httpclient.protocol.ReflectionSocketFactory.createSocket(ReflectionSocketFactory.java:139)
> at
> org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:124)
> at
> org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:706)
> at
> org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:386)
> at
> org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:170)
> at
> org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396)
> at
> org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)
> at
> org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:558)
> at
> org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:176)
> ... 8 more
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]