File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes Connection reset by peer: socket write error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Connection reset by peer: socket write error" Watch "Connection reset by peer: socket write error" New topic
Author

Connection reset by peer: socket write error

Olivier Daguenet
Greenhorn

Joined: Dec 27, 2005
Posts: 6
Hi all,
I have a Web service Java called by Java Class with a Axis server and Win XP.
I make tests on my Web service and for this, I call it successively with several threads:
here is the code of calling class which is constituted by 2 classes:
The 1st class :

public class Client
{
public static void main(String[] args)
{
try
{
for (int i = 0; i<51; i++)
{
ClientCallWS callWS = new ClientCallWS(args, i);
System.out.println(" call start " + i);
callWS.start();
}
}
catch (Exception e)
{
System.out.println("error : " + e.getMessage());
}
}
}

The 2nd class (calld by "Client") :

import java.io.BufferedReader;
import java.io.FileReader;

import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;

public class ClientCallWS implements Runnable
{
private Thread thread;
private String[] argsMain;
private int cnt;

public ClientCallWS(String[] args, int count)
{
argsMain = args;
cnt = count;
thread = new Thread(this);
}

public void start()
{
thread.start();
}

public void join()
{
try
{
thread.join();
}
catch (Exception e)
{
System.out.println("error : " + cnt + " - " + e.getMessage());
}
}

public void run()
{
try
{
System.out.println("run : " + cnt);
String str = null;
BufferedReader br = new BufferedReader(new FileReader(argsMain[0]));
StringBuffer sb = new StringBuffer();

while ((str = br.readLine()) != null)
{
sb.append(str + "\n");
}

str=sb.toString();
callWS(argsMain,str);
}
catch (Exception e)
{
System.out.println("error : " + cnt+ " - " + e.getMessage());
}
}

private String callWS(String[] args, String chaine)
{
String ret=null;

try
{
String UrlService = args[1];

Service service = new Service();

Call call = (Call) service.createCall();

call.setTargetEndpointAddress(new java.net.URL(UrlService));

call.setOperationName( new QName("AnalyseDossier", "InterrogerOADPartRPC"));

call.addParameter("arg1", XMLType.XSD_STRING, ParameterMode.IN);
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
long debut =System.currentTimeMillis();
ret = (String) call.invoke(new Object[] { chaine } );

System.out.println("Response " + cnt);
System.out.println("callWS : response duration is :" + String.valueOf(System.currentTimeMillis()-debut));
}
catch (Exception e)
{
System.out.println(e.Message());
e.printStackTrace(System.out);
System.exit(0);
}
return ret;
}
}

In the "for" of "Client", I indicate the number of threads I send.
Until 50 Threads, it works quite fine, but it's long because the webservice answers threads one by one but not Independently...
If I throw 51 threads, during the treatment of the first call, I've this error :

2005-12-29 09:03:00,886 INFO [main] org.apache.axis.transport.http.SimpleAxisWorker.execute - Exception:
java.net.SocketException: Connection reset by peer: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(Unknown Source)
at java.net.SocketOutputStream.write(Unknown Source)
at org.apache.axis.transport.http.SimpleAxisWorker.execute(SimpleAxisWorker.java:479)
at org.apache.axis.transport.http.SimpleAxisWorker.run(SimpleAxisWorker.java:155)
at org.apache.axis.transport.http.SimpleAxisServer.run(SimpleAxisServer.java:245)
at org.apache.axis.transport.http.SimpleAxisServer.start(SimpleAxisServer.java:296)
at org.apache.axis.transport.http.SimpleAxisServer.start(SimpleAxisServer.java:304)
at org.apache.axis.transport.http.SimpleAxisServer.main(SimpleAxisServer.java:385)
at ws.commun.Initialisation.demarrerServeurAxis(Initialisation.java:217)
at ws.commun.Initialisation.main(Initialisation.java:70)

ws.commun.Initialisation is the java class which starts the Axis server by this command : SimpleAxisServer.main(8080);

Questions :
- is there sommeone who can tell me the reaseon of the error ?
- Why my WebService do not deals the threads Independently ?

Thanks in advance for your help.
Olivier51
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41604
    
  55
Could it be that your server is configured not to accept more than 50 simultaneous incoming connections?


Ping & DNS - my free Android networking tools app
 
jQuery in Action, 2nd edition
 
subject: Connection reset by peer: socket write error