Return-Path: X-Original-To: apmail-cayenne-user-archive@www.apache.org Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 56880186CD for ; Fri, 8 Apr 2016 05:06:28 +0000 (UTC) Received: (qmail 74173 invoked by uid 500); 8 Apr 2016 05:06:28 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 74155 invoked by uid 500); 8 Apr 2016 05:06:27 -0000 Mailing-List: contact user-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cayenne.apache.org Delivered-To: mailing list user@cayenne.apache.org Received: (qmail 74143 invoked by uid 99); 8 Apr 2016 05:06:27 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Apr 2016 05:06:27 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 20F901804FC for ; Fri, 8 Apr 2016 05:06:27 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.003 X-Spam-Level: X-Spam-Status: No, score=-0.003 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (1024-bit key) header.d=netorg75979.onmicrosoft.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id rp-2ZHyX8thN for ; Fri, 8 Apr 2016 05:06:25 +0000 (UTC) Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1on0147.outbound.protection.outlook.com [157.56.110.147]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 8CED65FB1C for ; Fri, 8 Apr 2016 05:06:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NETORG75979.onmicrosoft.com; s=selector1-valsphere-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=tFvICet8J7YABz1SxHYczQ13s5Ffb6cZjiR8JN8q2YM=; b=ZadHHcOMTRT/fXfug6xwG5co0Qc9ATzOjwjYZi2uXPas0DjygmwPqw0rhnLpb4NcTFfTEaKyB+HOzlLl5dl0wEvGygeKX674+bL/luKIUd2n7B5p4gcr8Pguhsub8Vm1MEezlQuCVcexC2dry7GpEjr4j7Usy2LmfWwjdtKI20o= Received: from BY2PR06MB2133.namprd06.prod.outlook.com (10.166.113.25) by BY2PR06MB2134.namprd06.prod.outlook.com (10.166.113.26) with Microsoft SMTP Server (TLS) id 15.1.453.26; Fri, 8 Apr 2016 05:06:17 +0000 Received: from BY2PR06MB2133.namprd06.prod.outlook.com ([10.166.113.25]) by BY2PR06MB2133.namprd06.prod.outlook.com ([10.166.113.25]) with mapi id 15.01.0453.027; Fri, 8 Apr 2016 05:06:17 +0000 From: Adam Boyle To: "user@cayenne.apache.org" Subject: Re: ROP: detecting that my client connection has timed out Thread-Topic: ROP: detecting that my client connection has timed out Thread-Index: AQHRkTRhBo0mbK7JM0uAc4s6CzVJ059/ariLgAARw4CAAAGzDg== Date: Fri, 8 Apr 2016 05:06:16 +0000 Message-ID: References: ,<6e4da15f-3f59-edca-bccd-e8994b0a6a5b@maniatis.org> In-Reply-To: <6e4da15f-3f59-edca-bccd-e8994b0a6a5b@maniatis.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: cayenne.apache.org; dkim=none (message not signed) header.d=none;cayenne.apache.org; dmarc=none action=none header.from=valsphere.com; x-originating-ip: [132.245.54.101] x-ms-office365-filtering-correlation-id: 4a0e586f-ca55-4baf-2467-08d35f6b8407 x-microsoft-exchange-diagnostics: 1;BY2PR06MB2134;5:D/ojSd4xxjscPUqFi1PhksjN2zAnO9CxQkmLd2GbCHruP74yDLbLknVlmaleQgjhjiJgRJQ3SLyfSQWHH9pxC9dPVuQwv/Bis9B5HAoDKjmdNgPYqnn7TyuhBRwrpXoSDrcvwoTBGFYhaKmm1QXa6Q==;24:vtzY4g1ZNWHpFS6R5fb6yHmvgjayPt7xXWBkYo5SMO0e2tAksZosR1coGtfarDTEJkr34rT3IxZFSD4rlPDrii+Y1jS9wgGkaOFsaY0nB1c= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR06MB2134; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040074)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6041046)(6043046);SRVR:BY2PR06MB2134;BCL:0;PCL:0;RULEID:;SRVR:BY2PR06MB2134; x-forefront-prvs: 0906E83A25 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(24454002)(377454003)(51914003)(43784003)(102836003)(1096002)(6116002)(3846002)(1220700001)(586003)(76576001)(5008740100001)(66066001)(77096005)(2950100001)(10400500002)(33656002)(2900100001)(86362001)(54356999)(76176999)(50986999)(107886002)(110136002)(189998001)(5002640100001)(2501003)(19580405001)(92566002)(3660700001)(5003600100002)(2351001)(3280700002)(3900700001)(106116001)(551544002)(9686002)(99286002)(2906002)(81166005)(74316001)(87936001)(122556002)(450100001)(11100500001)(5004730100002)(19580395003);DIR:OUT;SFP:1102;SCL:1;SRVR:BY2PR06MB2134;H:BY2PR06MB2133.namprd06.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; spamdiagnosticoutput: 1:23 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: valsphere.com X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Apr 2016 05:06:16.8853 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 552f1932-42eb-4db3-a137-fd645bffe074 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR06MB2134 Thanks for the response. I could be overlooking it, but I don't see an answ= er to my central question: how can I detect that the client has timed out? = The nature of our application prevents us from using a keep-alive type solu= tion; it is meant to be used in highly regulated environments (which is one= of the reasons I chose Cayenne ROP: it provides a way to hide the database= details from the users). Even if I could use an auto-reconnect solution, I= would still need to be able to detect that the connection has timed out, a= nd I have failed to find a way to actually detect that. I suppose that another (less-hacky) way I could approach this would be to l= ogically detect a "timeout" by keeping the actual connection alive and stor= ing login session info in the database and updating it with the current dat= e time every time a Cayenne action is performed. This code would check for = a timeout beforehand and prompt the user to re-authenticate before performi= ng said action. The main problem there is maintainability; I'd have to add = this check to every place I intend to submit any sort of Cayenne action unl= ess there is a way to hook this sort of check into the ObjectContext. Does anyone know of a better way? Perhaps some advice for this novice enter= prise developer? Thanks again, Adam ________________________________________ From: Aristedes Maniatis Sent: Friday, April 8, 2016 12:30 AM To: user@cayenne.apache.org Subject: Re: ROP: detecting that my client connection has timed out On 8/04/2016 1:28pm, Adam Boyle wrote: > Is there a simple way of detecting that the connection is dead so that I = can prompt the user to reconnect? I don't think you need to prompt the user if you keep the user's authentica= tion details in memory. Just create a new session with them. > On a related note, what happens to the existing client ObjectContext obje= cts that are in use if the connection is able to be re-established? Are the= uncommitted PersistentObjects previously created in those contexts lost fo= rever? Those contexts are no longer associated with a session on the server (once = your session times out). So you either have to recognise that a user is con= necting again after a connection error and give them a handle on the same s= ession id they had last time, or else start a new session and lose the old = contexts. The problem is: can you be sure the state of those contexts still make sens= e? > The only (hacky) solution I can think of is to actually run a keep-alive = thread to periodically send a low-latency query to Cayenne to keep the ROP = session active and separately track application activity and prompt the use= r to enter their password if a certain period of time has passed with no ac= tivity. The problem that I see with an approach like that is that there are= lots of ways that activity could be missed, the application is not truly t= iming out, and it really doesn't address the underlying problem which is th= at sessions need to time out for a reason and there doesn't seem to be a wa= y to detect such a timeout. Well this is outside Cayenne itself, but part of the reason we recently did= the work in trunk (CAY-2065) to untangle Cayenne from Hessian and from the= HTTP layer. Then you can manage the session more easily yourself to do wha= tever you want. For example, we have a ping every minute from the client that: * keeps the session alive (we don't want the session to die just because th= e user went to have lunch) * allows us the keep the server-side session timeout quite low (good to exp= ire sessions for users who dropped off the network without a proper logout) * allows the server to track which users are having network issues In the last six months we've been doing a bunch of work with ActiveMQ/STOMP= which might eventually replace that ping. That way we have two way server-= client communication and the server can quickly see which clients have lost= network connection without a ping. Nice to see a fellow Cayenne ROP user. There aren't many of us and it is re= ally a very powerful bit of functionality. Ari -- --------------------------> Aristedes Maniatis GPG fingerprint CBFB 84B4 738D 4E87 5E5C 5EFA EF6A 7D2E 3E49 102A=