[ 
https://issues.apache.org/jira/browse/HTTPCORE-118?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Halo chen reopened HTTPCORE-118:
--------------------------------


Hi Oleg,
     Follow your suggestion, I change my test code and test it and the 
application is crashed!!! you can see the attachment.
     Actually, I think it's a very normal thing that the http server is opened 
thousands of connections in a tight loop and immediately closed then after 
having executed just one request . Thousands of people request the http server 
at the same time will open thousands of connections. 
     I agree with you, according the HTTP/1.1 standard, the headers must 
include the line "Connection: close" to tell the server should close the socket 
after finished this time request.  But I think that the server should close the 
socket   and release all resources  hold by the connection if the client close 
the socket firstly, right? If i'm not right, why  the httpcore keep the 
connections? The socket had be closed, nothing can be read/written! 
     I think the httpcore should handle these abnormal requests to enhance the 
stabilization.
    

> Some strange issue under a heavy  stress test
> ---------------------------------------------
>
>                 Key: HTTPCORE-118
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-118
>             Project: HttpComponents Core
>          Issue Type: Bug
>          Components: Examples, HttpCore, HttpCore NIO
>    Affects Versions: 4.0-alpha5
>         Environment: Windows xp(sp2), JDK 1.5
>            Reporter: Halo chen
>            Priority: Critical
>             Fix For: 4.0-alpha5
>
>         Attachments: a.txt, SendToIA.java, snapshot.jpg
>
>
> Thanks very much for your contributions.
> I use your httpcore to develop a embed web application, very well, I think. 
> But, when i do some stress test, i find a strange issue, please see my test 
> case:
> public class SendToIA implements Runnable {
>       String[] args;
>       SendToIA( String[] args )
>       {
>               this.args = args;
>       }
>       public void run()
>       {
>               try {
>                       FileInputStream fis = new FileInputStream("a.txt");
>                       int len = fis.available();
>                       byte[] buf = new byte[len];
>                       fis.read(buf);
>                       fis.close();
>                       String ReuestHead = "POST /TerminalLocationNotification 
> HTTP/1.1\r\nHOST: LOCALHOST\r\nContent-Length: ";
>                       String ReuestLen = String.valueOf(len) + "\r\n\r\n";
>                       String RequestBody = new String(buf);
>                       String httpRequest = ReuestHead + ReuestLen + 
> RequestBody;                      
>                       String host = "localhost";
>                       int port = 8086;
>                       if( args.length == 1 )
>                       {
>                               host = args[0];
>                       }
>                       else if( args.length == 2 )
>                       {
>                               host = args[0];
>                               port = Integer.parseInt( args[ 1 ] );
>                       }
>                       
>                       System.out.println(new java.util.Date());
>                       for (int i = 0; i < 20000; i++) {
>                               Socket connection = new Socket( host, port );
>                               connection.setReuseAddress( true );
>                               PrintWriter out = new 
> PrintWriter(connection.getOutputStream(), true);
>                               out.print(httpRequest);
>                               out.flush();
>                               connection.close();             
>                               System.out.print("\b\rcont:"+i);
>                       }
>                       System.out.println(new java.util.Date());
>               } catch (SecurityException e) {
>                       e.printStackTrace();
>               } catch (Exception e) {
>                       e.printStackTrace();
>               }
>       }
>       public static void main(String[] args) throws IOException {
>               int threadcount = 1;
>               if( args.length == 3 )
>               {
>                       threadcount = Integer.parseInt( args[ 2 ] );
>               }
>               Thread[] t = new Thread[ threadcount ];
>               for( int i = 0 ; i < threadcount ; i ++ )
>               {
>                       new Thread( new SendToIA( args )        ).start();
>               }
>               for( int i = 0 ; i < threadcount ; i ++ )
>               {
>                       try{t[i].join();}catch( Exception e ){}
>               }
>       }
> }
> Unfortunately, the application was crashed. 
> The first , I think my application has some mistake. so I run the example( 
> org.apache.http.examples.nio.NHttpServer) in the HttpCore binary package. 
> Oh,No!
> The same issue was occured! 
> Why? I found the memory usage of the application reach 170M!!, and then I add 
> the JVM parameter -Xmx256M.Okay, the application can running continue. but 
> after a long time, the memory usage of the application reach 256M and then 
> the same thing was occured! So , I think that the HttpCore has some memory 
> leak.
> Can you give me some advices to resolve this issue? or I have some mistakes?
> details of error occured:
> ...
> Exception in thread "I/O reactor worker thread 2" java.lang.OutOfMemoryError: 
> Java heap space
> ....
> java.lang.NullPointerException
>       at 
> org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.verifyWorkers(AbstractMultiworkerIOReactor.java:136)
>       at 
> org.apache.http.impl.nio.reactor.DefaultListeningIOReactor.execute(DefaultListeningIOReactor.java:111)
> ....
> Exception in thread "I/O reactor worker thread 8" java.lang.OutOfMemoryError: 
> Java heap space
> Exception in thread "Thread-6" java.lang.OutOfMemoryError: Java heap space
> Sorry , I'm chinese , my english is bad, may be i haven't explain the issue 
> clearly. but I need your help.

-- 
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]

Reply via email to