Return-Path: X-Original-To: apmail-hc-dev-archive@www.apache.org Delivered-To: apmail-hc-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 06AE210892 for ; Thu, 25 Jul 2013 08:00:17 +0000 (UTC) Received: (qmail 19682 invoked by uid 500); 25 Jul 2013 08:00:16 -0000 Delivered-To: apmail-hc-dev-archive@hc.apache.org Received: (qmail 19654 invoked by uid 500); 25 Jul 2013 08:00:15 -0000 Mailing-List: contact dev-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list dev@hc.apache.org Received: (qmail 19637 invoked by uid 99); 25 Jul 2013 08:00:14 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Jul 2013 08:00:14 +0000 X-ASF-Spam-Status: No, hits=0.0 required=5.0 tests=T_FRT_STOCK2 X-Spam-Check-By: apache.org Received-SPF: error (athena.apache.org: local policy) Received: from [217.150.250.48] (HELO kalnich.nine.ch) (217.150.250.48) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Jul 2013 08:00:09 +0000 Received: from [192.168.42.106] (unknown [213.55.184.250]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by kalnich.nine.ch (Postfix) with ESMTPSA id 26026B8222F; Thu, 25 Jul 2013 09:59:27 +0200 (CEST) Message-ID: <1374739164.31328.14.camel@ubuntu> Subject: Re: Migrating Synapse to Latest HTTP Core From: Oleg Kalnichevski To: HttpComponents Project Cc: dev@synapse.apache.org Date: Thu, 25 Jul 2013 09:59:24 +0200 In-Reply-To: References: <3980392C-6E73-413D-92EC-F757708E639E@gmail.com> <0A5E1BEC-B8B7-4D2F-A266-FC2120D5F1A6@gmail.com> <1374564731.322.6.camel@ubuntu> <331FFBE1-67A8-4C91-8F3E-EFF0033E55A2@gmail.com> <797416BC-69D9-4039-9577-8484B8402299@gmail.com> <1374650279.12997.3.camel@ubuntu> <1374666346.12997.9.camel@ubuntu> <1374670149.12997.29.camel@ubuntu> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.8.2-0ubuntu1~raring1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org On Wed, 2013-07-24 at 11:04 -0700, Hiranya Jayathilaka wrote: > Hi Oleg, > > Thanks for your great insights. Now I'm able to get all the unit tests and integration tests to run successfully. > > BTW do you have any idea as to what changed between 4.1.x and 4.2.x to cause this behavior? Our test suites work fine on current Synapse trunk which is based on HTTP Core 4.1.4. > Hi Hiranya Prior to 4.2 HttpCore did not explicitly set SO_REUSEADDRESS parameter on server sockets and relied on platform specific default behavior. Oleg > Also do you think it's a good idea to make SoReuseAddress=true the default in Synapse? Do you see any potential issues with that? > > Thanks, > Hiranya > > On Jul 24, 2013, at 5:49 AM, Oleg Kalnichevski wrote: > > > On Wed, 2013-07-24 at 13:45 +0200, Oleg Kalnichevski wrote: > >> On Wed, 2013-07-24 at 01:40 -0700, Hiranya Jayathilaka wrote: > >>> Hi again, > >>> > >>> On Jul 24, 2013, at 1:36 AM, Hiranya Jayathilaka > >>> wrote: > > > > ... > > > >>> > >>> I've also noticed that the problem doesn't occur if we do not send any > >>> messages in the 1st round. I verified this behavior with Synapse too. > >>> If a test case doesn't send any messages to Synapse, the test case > >>> that follows will run without any issues. > >>> > >> > >> Hiranya > >> > >> (1) The socket is CLOSE_WAIT state is from the client connection. It has > >> nothing to do with the problem and can be gotten rid of by shutting down > >> the client connection pool. > >> > >> client.getConnectionManager().shutdown(); > >> > >> (2) The 'Address already in use' problem goes away if the server is > >> configured to re-use socket address > >> > >> reactorConfig.setSoReuseAddress(true); > >> > >> I think this option should be activated for integration tests running > >> inside the same JVM anyway, but I'll investigate why the address remains > >> bound even after the listener has been shut down. I am not yet sure > >> whether this is a bug or an expected behavior. > >> > >> Oleg > >> > >> > > > > Just a quick follow-up. The problem appears to be Linux specific. The > > same test app works fine for me on Windows XP. > > > > I also modified slightly your code in order to have a finer control over > > the client side. > > --- > > System.out.println("Round 1"); > > initServer(); > > > > DefaultHttpClientConnection conn = new DefaultHttpClientConnection(); > > try { > > Socket socket = new Socket("localhost", 8280); > > conn.bind(socket, new BasicHttpParams()); > > conn.setSocketTimeout(1000); > > conn.sendRequestHeader(new BasicHttpRequest("GET", "/")); > > conn.flush(); > > conn.receiveResponseHeader(); > > } catch (SocketTimeoutException ex) { > > } finally { > > conn.close(); > > // this closes the socket the connection is bound to > > } > > > > System.out.println("Waiting - Shutdown in 5 secs"); > > Thread.sleep(5000); > > shutdown(); > > > > System.out.println("\n\nRound 2"); > > initServer(); > > System.out.println("Waiting - Shutdown in 5 secs"); > > Thread.sleep(5000); > > shutdown(); > > --- > > > > If you just comment out the conn#receiveResponseHeader() statement the > > client side socket will never be put into read mode, and (surprise, > > surprise) the listener address will no longer be stuck in the bound > > state. > > > > I am neither a Linux nor a TCP/IP specialist. I cannot tell why this is > > happening. However, by the look of it, one must use 'SO_REUSE_ADDRESS' > > option on Linux in order to be able to shut down and re-open the > > listener on the same address if the socket bound to that address had > > some data passing through it. > > > > Anyone happens to have an idea? > > > > Oleg > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: dev-unsubscribe@synapse.apache.org > > For additional commands, e-mail: dev-help@synapse.apache.org > > > > -- > Hiranya Jayathilaka > Mayhem Lab/RACE Lab; > Dept. of Computer Science, UCSB; http://cs.ucsb.edu > E-mail: hiranya@cs.ucsb.edu; Mobile: +1 (805) 895-7443 > Blog: http://techfeast-hiranya.blogspot.com > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org For additional commands, e-mail: dev-help@hc.apache.org