Author |
|
hmuscroft Groupie
Joined: 29 December 2009 Location: United Kingdom
Online Status: Offline Posts: 72
|
Posted: 02 February 2017 at 3:34am | IP Logged
|
|
|
In my app, I do some "connection caching" to improve performance.
Basically, when an "Imap" object is constructed, it is cached and then re-used for further operations on the same IMAP server, to save having to repeatedly re-connect and re-login.
After a period of inactivity (usually a few minutes), the cached Imap objects will throw one of the following exceptions when re-used :-
- MailBeeAbortedByRemoteHostException
- MailBeeSocketResetException
This isn't a big problem as I can just destroy the now invalid Imap object, re-create it, login and retry the operation.
However I have two questions please :-
[1] Whenever I'm about to re-use a cached Imap object, I call the ".IsConnected" proeprty to check if it's still connected. It always seems to return TRUE, but then when I then perform the operation, I get one of the 2 exceptions mentioned above.
Presumably .IsConnected doesn't actually check with the server to see if it really is still connected? Is there a different method/property to use to achieve this?
[2] Does the above approach (with regard to caching IMAP objects) sound reasonable or would you recommend a different approach?
Many thanks for your excellent continued support!
Regards,
Hedley
|
Back to Top |
|
|
Alex AfterLogic Support
Joined: 19 November 2003
Online Status: Offline Posts: 2206
|
Posted: 02 February 2017 at 3:41am | IP Logged
|
|
|
[1] Yes, IsConnected just reports the last known object state.
[2] You can call Noop every minute or so to keep connection alive (you'll still need to handle exceptions above).
Regards,
Alex
|
Back to Top |
|
|
hmuscroft Groupie
Joined: 29 December 2009 Location: United Kingdom
Online Status: Offline Posts: 72
|
Posted: 02 February 2017 at 3:46am | IP Logged
|
|
|
Ah OK... so would you recommend calling "Noop()" at intervals, or would it be better to call ".Noop()" in place of ".IsConnected" before an operation to test if the connection is still valid and then re-create it if not?
I guess that I'm concerned that if the client app has 10 IMAP accounts, and there are 20 network users all logged on (to their own instance of the app), then that's 200 imap connections being "Noop'ed" every minute to keep them open.
|
Back to Top |
|
|
Igor AfterLogic Support
Joined: 24 June 2008 Location: United States
Online Status: Offline Posts: 6103
|
Posted: 02 February 2017 at 3:51am | IP Logged
|
|
|
To minimize traffic, you can use IDLE approach for every connection, you can find the detailed description and sample here.
--
Regards,
Igor, AfterLogic Support
|
Back to Top |
|
|
hmuscroft Groupie
Joined: 29 December 2009 Location: United Kingdom
Online Status: Offline Posts: 72
|
Posted: 02 February 2017 at 6:18am | IP Logged
|
|
|
OK - thanks for that.
|
Back to Top |
|
|