Return-Path: X-Original-To: apmail-tomcat-users-archive@www.apache.org Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E4342102C7 for ; Fri, 5 Apr 2013 20:23:03 +0000 (UTC) Received: (qmail 47889 invoked by uid 500); 5 Apr 2013 20:23:00 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 47829 invoked by uid 500); 5 Apr 2013 20:23:00 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 47819 invoked by uid 99); 5 Apr 2013 20:23:00 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Apr 2013 20:23:00 +0000 X-ASF-Spam-Status: No, hits=1.7 required=5.0 tests=FREEMAIL_ENVFROM_END_DIGIT,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of smithh032772@gmail.com designates 74.125.82.170 as permitted sender) Received: from [74.125.82.170] (HELO mail-we0-f170.google.com) (74.125.82.170) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Apr 2013 20:22:54 +0000 Received: by mail-we0-f170.google.com with SMTP id z2so3215801wey.29 for ; Fri, 05 Apr 2013 13:22:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=d+F7wm+jn8LbNjaePfHyj6Y/URLJrv7p5Rbueq7XtmA=; b=SKXo5MIwHJKcUJWo3Gig8jsgBP9wD4OzmBr0UNoc5nM0/VuGKNIhHtC27pzQcKf7ly 10n9U/P3XQJPEMKU1wkLytwAVJg0AK886yOQAfI+H8A9S0WpGBggrrdN+M3FfJX0FJb7 GPhpy+wkQwKcW/bfDQ/haigaUgCr+msHjcroYJ/g6T3mabc+OJBza32SVIWbs2ssv+1m WmfXGEojMhFzZY26lfkgg4O3Th4gjGCST3/tdwnDU8DQTk0eUxULinMS96+hzrXDdyaA orxQNTRvD7gCP8tGbLjac3Bgu9x/a+Fk3N04xccMNn09AyEvbtSGNG7/YRfbbhC5qhFS VzpA== MIME-Version: 1.0 X-Received: by 10.180.13.34 with SMTP id e2mr866898wic.29.1365193354136; Fri, 05 Apr 2013 13:22:34 -0700 (PDT) Received: by 10.227.25.194 with HTTP; Fri, 5 Apr 2013 13:22:33 -0700 (PDT) In-Reply-To: References: Date: Fri, 5 Apr 2013 16:22:33 -0400 Message-ID: Subject: Re: websockets holding on to threads. From: "Howard W. Smith, Jr." To: Tomcat Users List Content-Type: multipart/alternative; boundary=001a11c2a85aec51ab04d9a2d836 X-Virus-Checked: Checked by ClamAV on apache.org --001a11c2a85aec51ab04d9a2d836 Content-Type: text/plain; charset=ISO-8859-1 On Fri, Apr 5, 2013 at 9:07 AM, Anton Piatek1 wrote: > I am seeing what at first appears to be a bug, but given the lack of other > reports I can't believe I am the only person seeing this, so maybe it is > user-error. > > I have tomcat (was 7.0.30, but I just tried with 7.0.39) running a website > which uses websockets. The websockets code in tomcat isn't that > complicated - My servlet returns a new subclass of StreamInbound which has > overridden the onTextData() and onBinaryData() methods. This seems to > generally work fine, and I can send and receive data happily. > > However when I load up several browser windows I find that tomcat hangs. I > used jconsole to check the tomcat threads and found that as I open each > new websocket, the tomcat worker threads go from idle threads waiting for > work to the following busy, blocking threads waiting for websocket data. > > I have not written low-level websocket code as you are doing, but I think I have seen this behavior even in/with my app, and others have reported and discussed this issue in more ways than one. I am using Atmosphere Framework via PrimeFaces Push to implement websockets in my app, and it does work well with one browser tab/window, but it is commonly reported that websockets do not work when one client (machine) has multiple simultaneous websocket connections to the server. Since I use Atmosphere Framework, I searched their google groups for the following: browser windows and found the following (URL and quote from page at URL below): https://github.com/Atmosphere/atmosphere/issues/493 According to HTTP RFC : Clients that use persistent connections SHOULD limit the number of simultaneous connections that they maintain to a given server. A single-user client SHOULD NOT maintain more than 2 connections with any server or proxy. This can cause problems if you have multiple tabs/window open, which all maintain a persistent connection. It would be great if persistent connections should be shared (as GWT or Bayeux Protocol does it). > Name: http-bio-4415-exec-5 > State: RUNNABLE > Total blocked: 50 Total waited: 112 > > Stack trace: > java.net.SocketInputStream.socketRead0(Native Method) > java.net.SocketInputStream.read(SocketInputStream.java:161) > java.net.SocketInputStream.read(SocketInputStream.java:132) > > org.apache.coyote.http11.upgrade.UpgradeBioProcessor.read(UpgradeBioProcessor.java:81) > org.apache.catalina.websocket.WsFrame.nextFrame(WsFrame.java:214) > > org.apache.catalina.websocket.WsInputStream.nextFrame(WsInputStream.java:68) > org.apache.catalina.websocket.StreamInbound.onData(StreamInbound.java:149) > > org.apache.coyote.http11.upgrade.UpgradeProcessor.upgradeDispatch(UpgradeProcessor.java:83) > > org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:587) > > org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310) > - locked org.apache.tomcat.util.net.SocketWrapper@ddb0d168 > > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1156) > > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:626) > java.lang.Thread.run(Thread.java:780) > > I am trying to figure out what I am missing. I didn't think I needed to > override StreamInbound.onData() in my class, but as that seems to be what > is keeping the thread busy, presumably waiting for data looking at that > stack. > > Am I misunderstanding something, or is this possibly a tomcat bug? > I don't think this is a tomcat bug, but I could be mistaking. > Unless stated otherwise above: > IBM United Kingdom Limited - Registered in England and Wales with number > 741598. > Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU > --001a11c2a85aec51ab04d9a2d836--