Keep Alive SMTP connection

Hi,
Is there any way to keep alive a SMTP connection forever using JavaMail? I know being a TCP connection, the connection will be broken if no data is exchanged for specific time. What if NOOP command is send to SMTP server as a heart beat. Can anybody suggest how this can be accomplished using JavaMail?
Thanks,
Atul

You can call the isConnected method, but your server isn't going to like you if you
keep a connection open even though you're not using it.

Similar Messages

  • Workstation keep-alive and connectivity failure detection

    Dear all,
    I intend to automatically detect network failures from my workstation client and have it attempt to reconnect to the server on its own.
    Browsing the documentation for related information I saw the keep-alive option. If I understood correctly you can have the workstation generate periodic keep-alive messages to the server and if these are not acknowledged, all subsequent ATMI calls will fail with TPESYSTEM.
    My doubts regarding this are the following:
    1) Is there some dummy ATMI function I can invoke periodically to check for a disconnection? Otherwise network failures might go by unnoticed if there are periods where my WSC doesn't require to communicate with the server.
    2) Once I get a TPESYSTEM failure, is there some way to programatically discriminate if the cause is a network disconnection? It is a pretty generic error after all.
    3) Once all ATMI functions start failing due to keep-alive detecting a network failure, can the system recover on its own? or must I reconnect to the server? What I mean is, maybe some keep alive messages where lost, the system passes to the 'disconnected' state, but then the K.A. messages keep being generated and upon correct acknowledgement of these, subsequent ATMI calls will stop failing.
    4) Does the WSC go to 'disconnected' state after the first unanswered keep alive message? or is there some sort of tolerance like, say, 'If N messages in a row are not answered then assume the connection to be dead'.
    I'm sorry if it was too long a post, but neither searching the documentation nor this forum clarified any of these issues for me.
    Many thanks for your attention.
    Regards.

    Cacho,
    1. I assume that you're talking about the WSL CLOPT option "-K
    {client|handler|both|none}", which causes periodic keepalive messages to be
    sent. When this option is used, there is no need for the WSC to perform any
    periodic operations to keep the network connection alive.
    However, if you are worried that the network might suffer a transient
    failure and you want to perform your first ATMI call after an extended
    period of inactivity as quickly as possible without waiting for another
    tpinit(), you may want to perform periodic dummy operations so that you can
    reissue the tpinit() if needed as soon as the network connection is
    restored.
    One option is to make a tpcall() to the ".TMIB" service with an FML32 buffer
    where TA_OPERATION is set to "GET" and the other fields are set to retrieve
    some system attribute. There is an example of how to call .TMIB at the end
    of the TM_MIB(5) manual page. You would want to perform a GET operation
    rather than the SET operation shown in that example.
    Another option is to write a null service in one of your application servers
    which just calls tpreturn() and have your client make periodic cals to that
    service.
    Calling a verb such as tpalloc() or tpconvert() would not be sufficient,
    since these calls do not result in any network traffic.
    2. The tperrordetail() function is available in newer releases of Tuxedo to
    provide additional information about certain Tuxedo errors. When a
    workstation client is disconnected, tperrordetail(0) will return TPED_TERM.
    3. If there is a network failure, workstation clients must call tpinit() to
    reauthenticate to the system. This is necessary for security reasons.
    4. The keepalive option is passed down to the underlying network provider
    and Tuxedo has no further involvement with keepalive once it informs the
    network of this option. For Sockets the option passed is SO_KEEPALIVE; you
    can do a web search on SO_KEEPALIVE to see exactly how the network treats
    keepalive messages on your particular platform.
    Ed
    <Cacho Nakamura> wrote in message news:[email protected]...
    Dear all,
    I intend to automatically detect network failures from my workstation client
    and have it attempt to reconnect to the server on its own.
    Browsing the documentation for related information I saw the keep-alive
    option. If I understood correctly you can have the workstation generate
    periodic keep-alive messages to the server and if these are not
    acknowledged, all subsequent ATMI calls will fail with TPESYSTEM.
    My doubts regarding this are the following:
    1) Is there some dummy ATMI function I can invoke periodically to check for
    a disconnection? Otherwise network failures might go by unnoticed if there
    are periods where my WSC doesn't require to communicate with the server.
    2) Once I get a TPESYSTEM failure, is there some way to programatically
    discriminate if the cause is a network disconnection? It is a pretty generic
    error after all.
    3) Once all ATMI functions start failing due to keep-alive detecting a
    network failure, can the system recover on its own? or must I reconnect to
    the server? What I mean is, maybe some keep alive messages where lost, the
    system passes to the 'disconnected' state, but then the K.A. messages keep
    being generated and upon correct acknowledgement of these, subsequent ATMI
    calls will stop failing.
    4) Does the WSC go to 'disconnected' state after the first unanswered keep
    alive message? or is there some sort of tolerance like, say, 'If N messages
    in a row are not answered then assume the connection to be dead'.
    I'm sorry if it was too long a post, but neither searching the documentation
    nor this forum clarified any of these issues for me.
    Many thanks for your attention.
    Regards.

  • Keep alive or Connect on Demand??!!

    My new router keeps on reconnecting/disconnecting byitself for some reason.... I wnt it to be on 24/7... My option is Connect on Demand atm, because I do not know what to keep near Keep alive option.. since there are seconds near it. PLZ HLP!!

    Well it is difficult to tell without knowing which router you have.
    Generally you find help in the manual which came on the CD with the router and is available online and in the help of the router web interface on the right. There you'll find something like this probably.

  • How to keep alive RS232 connection

    Hello everyone. I have a problem with RS232 communication. To activate the connection I have to send the string "RS232", then to keep it alive I have to send every second CR, but in the meantime, I must be able to send other character strings without delay on the same port (COM7). Can anyone help me?
    Thanks 
    Solved!
    Go to Solution.

    RS232 standard does not require by itself to be kept alive someway, so I suppose is your remote device that requires it.
    In every case, you could create a 1-sec timer and have its callback send CR periodically over the serial port.
    To avoid conflicts between this task and the rest of the application you could use a lock: basically, after creating the lock, each function that wants to access the serial port must call CmtGetLock (), operate on the port and call CmtReleaseLock () afterwards. If the lock is owned by another function, other functions trying to get access are frozen waiting for the lock, so you must be careful in designing com-related function so that they are fast. If you do not want to have some function be blocked while waiting for the lock you can use CmtTryToGetLock instead of CmtGetLock. A few informations on locks can be found in this tutorial as well as in this chapter of the Programmer reference.
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

  • Weblogic proxy plugin closes keep-alive connections to clients randomly

    In short we have following arhitecture:
    clients ---> wl proxy plugin 1 ----> weblogic 1
    clients ---> wl proxy plugin 2 ----> weblogic 2
    Beacuse of the application/installation specific requirements, we are not using failover, one wl proxy always forwards requests to one weblogic (simple configuration).
    Application is TR-069 protocol based (SOAP over HTTP) so it very much relays on persistence TCP connections (Connection: keep-alive). This TCP persistence has to work correctly in order that TR-069 messages are exchanged in required order, otherwise we have a error on application layer.
    Here and there we've noticed applications errors which suggest that we have some problems in TCP connection between the client and the weblogic server. After sniffing, we've noticed that weblogic proxy plugin (Apache) randomly, or because of some other reason we do not know, decides to close TCP connection to client, even app on weblogic did not request so ???
    As a result, client opens new connection to the server with new TR-069 session and it gets bounced beacuse it allready has one open on weblogic server.
    We've sniffed, traced everything we could, we were searching for patterns in time, etc... but we can not find the reason why proxy plugin decides to close the connection to the client (not to the weblogic server).
    Trace (replaced sensitive information):
    Thu Apr 29 15:05:50 2010 <958012725463463784> URL::parseHeaders: CompleteStatusLine set to [HTTP/1.1 200 OK]
    Thu Apr 29 15:05:50 2010 <958012725463463784> URL::parseHeaders: StatusLine set to [200 OK]
    Thu Apr 29 15:05:50 2010 <958012725463463784> parsed all headers OK
    Thu Apr 29 15:05:50 2010 <958012725463463784> sendResponse() : r->status = '200'
    Thu Apr 29 15:05:50 2010 <958012725463463784> canRecycle: conn=1 status=200 isKA=1 clen=545 isCTE=0
    Thu Apr 29 15:05:50 2010 <958012725463463784> closeConn: pooling for '$IP$/$PORT$'
    Thu Apr 29 15:05:50 2010 <958012725463463784> request [$URL$] processed successfully..................
    !!!! Now it closes the TCP connection and inserts "Connection: close" HTTP header !!!
    WL proxy plugin conf params are:
    WebLogicCluster $IP$:$PORT$
    DynamicServerList OFF
    KeepAliveTimeout 90
    MaxKeepAliveRequests 0
    KeepAliveSecs 55
    Apache worker configuration is:
    <IfModule mpm_worker_module>
    PidFile var/run/httpd-worker.pid
    LockFile var/run/accept-worker.lock
    StartServers 2
    MinSpareThreads 25
    MaxSpareThreads 75
    ThreadLimit 200
    ThreadsPerChild 200
    MaxClients 2000
    MaxRequestsPerChild 0
    AcceptMutex pthread
    </IfModule>
    Why weblogic proxy plugin ignores Keep-alive directive and decides to close connection to the client by itself?
    Any help?

    If a WebLogic Server instance listed in either the WebLogicCluster parameter or a dynamic cluster list returned from WebLogic Server fails, the failed server is marked as "bad" and the plug-in attempts to connect to the next server in the list.
    MaxSkipTime sets the amount of time after which the plug-in will retry the server marked as "bad." The plug-in attempts to connect to a new server in the list each time a unique request is received (that is, a request without a cookie).
    Note: The MaxSkips parameter has been deprecated as the MaxSkipTime parameter.
    See also here: http://download-llnw.oracle.com/docs/cd/E13222_01/wls/docs81/plugins/plugin_params.html
    You said the problem arises under significant load. Maybe, it is wise to tune the number file descriptor's on your operating system. HTTP connections are nothing more than TCP sockets on the operating system. All modern operating systems treat sockets as a specialized form of file access and use data structures called file descriptors to track open sockets and files for an operating system process. To control resource usage for processes on the machine, the operating system restricts the number of open file descriptors per process. You should be aware that all TCP connections that have been gracefully closed by an application will go into what is known as the TIME_WAIT state before being discarded by the operating system.
    On most unix systems you can use netstat -a | grep TIME_WAIT | wc -l to detemine the number of socket in time_wait state. You have to check with your system adminstrator how to tune the tcp_time_wait_interval. On solaris you can use: /usr/sbin/ndd -set /dev/tcp tcp_time_wait_interval 60000

  • How do I change the http connection type from close to keep-alive

    I am using a browser that appears as though it needs a connection type of keep-alive. When a page is requested the server sends back a connection type of close. It appears images are not requested from the server when this connection type is requested.

    Some older web server provides inaccurate content-length information.If the content length value is less than the amount of data,the web server treats the difference as a new request, this creates problem with iplanet Web Server.
    If you are using browser with HTTP1.1 enabled, choose the option to enable it manually and try once again by posting the request.
    Hope it helps.

  • Keep-alive message bridge connection

    Hi,
    I have setup messaging bridge between WLS 10.3.0.0 and a JBoss Messaging queque, after about 4 hours of inactivity in a queue bridge was disconneted, is there any way to configure keep-alive connection in WLS bridge ?
    Thanks,
    Lukasz

    You can try to set the IdleTimeMaximum setting on your bridge configuration to a very large number. It specifies the maximum amount of time, in seconds, that a messaging bridge instance remains idle.
    In “asynchronous” mode, this is the longest amount of time a messaging bridge instance stays idle before it checks the sanity of its connection to the source. In “synchronous” mode, this is the amount of time the messaging bridge can block on a receive call if no transaction is involved.
    -Dongbo

  • LDAP keep-alive connection ? (use of ldap_io_fns)

    Hi there,
    I am facing a new req. from network security guys that want to close 'idle' connections that crosses firewalls. But as I do use persistent search connection which are not very 'busy' => i.e. not enough traffic to be kept open by FireWall rule.
    Consequence my client could not 'detect' this cut of connection and do not receive any more the 'updates' through persistent search.
    I am now trying to init my connection setting optional io_fns structure changing the socket func by my socket func that do create a keep-alive socket.
    But it does not bind properly ... Init seem ok but bind never get out. LDAP receives bind and do log it but seem not able to respond properly ...
    Any idea on how to use this io_fns struct ?
    Many thanks.
    Hedi.
    .

    the problem is not that process is in foreground or background: the problem is the timeout: I need to avoid timeout, because the idea is to launch the report and then go out for lunch So I need to find a way in the code to advise the system that user has not to be logged out.
    Thanks
    Gabriele

  • HTTP persistent connection (keep Alive) problem

    Hi,
    I'm trying to deploy a RPC web service and I would like to use the HTTP 1.1 keep alive feature (which should be the default).
    I generated the server side and client side code using jdev 903. The AS is OC4j 903.
    The problem is that the server is sending a ‘Connection: close:’ header in the SOAP response, despite the client sending a ‘Connection: keep-alive’ header in the request. This is obviously causing the client to close the connection and open another for the next message.
    The documentation implies that the server will always try to use persistent connections, even so, in the file:
    <OC4J_HOME>/j2ee/home/config/http-web-site.xml
    there is a config option ‘use-keep-alives’. Setting this to true has no effect.
    I’m guessing there must be another option somewhere to turn on connection persistence.
    Can anyone please help ?

    Does anyone know whether Oracle Supports persistent connections ?
    I tested this on JBOSS and I seems to get better performance.
    cheers.

  • Keep alive connection

    Hi,
    I write a report that works on a lot of data and when it starts, it takes about an hour or two for processing. The problem is that on the system there is a timout of 20 minutes of inactivity after which the use il logged out.
    The question is: is there a way by code to advise a sort of keep alive so that user is not logged out?
    (I can't change the timeout on the system for security issues)
    Thanks
    Gabriele

    the problem is not that process is in foreground or background: the problem is the timeout: I need to avoid timeout, because the idea is to launch the report and then go out for lunch So I need to find a way in the code to advise the system that user has not to be logged out.
    Thanks
    Gabriele

  • HFM Web Sever Configuration--Keep Alive and Session Time Out Optimal Config

    We recently implemented an HFM 9.3.1 environment. We are using Windows 2003 Enterprise SP2 servers with IIS6. We have two HFM Web servers connecting to an application cluster with two application servers in the cluster. We were getting some errors when trying to unlock HFM cells in Workspace, but we were able to perform the functions fine on the application using the WIN32 client.
    I opened a ticket with support and they recommended modifying the subcontext.properties file located in %HYPERION_HOME%\deployments\WebLogic9\servers\Workspace\webapps\workspace\conf. They recommended changing the following settings:
    #KeepAliveInterval=30
    #SessionTimeout=60
    From what I understand, these settings are for the communication between the HFM Web Servers and the application cluster servers. I'm wondering how changing these settings may affect our environment. Are there negative effects and/or trade-offs for changing these settings? Is there a recommended threshold or maximum value?

    Hi Dinesh,
    This cannot be achieved without development enhancements to some standard SAP framework component, to introduce a "keep-alive" concept. If you are using a CMS for CTI or email integration, you need to ensure it supports keeping the communications session alive also.
    Sincerely,
    Glenn
    Glenn Abel
    Covington Creative
    www.covingtoncreative.com

  • WRT54G v 7.0 -- Setting "Keep Alive: Redial Period" not correct (radio button)

    Hi,
    I own a Linksys-Router WRT54G v7.0 with firmware v7.00.8 build 008, Jul. 9, 2009.
    On the web GUI (Setup/Basic Setup) there's a setting "Keep Alive: Redial Period XX Sec.". As I'd like to stay connected with my provider permanently, I've set the radio button to "Keep Alive: Redial Period" and the according text field to "30" seconds. Then, I've clicked "Save Settings" and got a confirmation message that the settings got saved.
    Anyway, even after saving the settings the according radio button is still set to "Connect on Demand...". But that is only true for newer browsers, like e.g. IE8, IE7 or Firefox 8. If you use an older browser, like e.g. IE6, then the radio button is correctly set to "Keep Alive: Redial Period" with a value of "30" seconds.
    Conclusion: The settings get correctly saved by the router (I can confirm that), but they don't get correctly shown in the web GUI. Looks like a HTML/Javascript bug in the router's admin web GUI. That's really annoying as you never exactly know the effective settings...
    Can someone confirm that bug? Is there a newer firmware than version 7.00.8? 
    Regards,
    Patrick

    Try to clear the browser's cache as well.
    "Don't fix it if it ain't broken."

  • Which port to use for the peer-keep alive

    Hi All,
    We have 2 Nexus 6001s in our data center.
    The management port of each 6001 is connected to the other and this link is used as the peer keep alive link.
    My colleague is suggesting that we use one of the inline data ports as the keep alive link.
    Can you please advise on the pros and cons of using management/inline port as keep live link and the best practise to follow in this case?
    Thanks,
    Pete

    Hi Pete,
    Here are the best recommendation in order of preference.
    1. Use mgmt0 (along with management traffic)
         * Pros: whats good on this option is you are totally separating the VPC Peer keepalive link on another VRF (management) and does not mingle with the data or global vrf..
         * Cons: VPC PKL is dependent on the OOB management switch.
    2. Use dedicated 1G/10GE front panel ports. 
        * Pros - can just be a direct link between the N6K pair and not dependent on other boxes. 
        * Cons - you need extra SFPs for VPC PKL while the VPC PKL traffic join the global VRF.
    HTH
    Jay Ocampo

  • Need help with HTTP keep-alive

    Hi folks!
    I have this very simple web server and I would like to add keep-alive support. I've been trying to get my head around it for a while and could need some help (I found this question in the archive, but those replies didn't help)...
    This is my starting point (stripped down to the basics):
    /* A listener thread that accept incoming requests by creating new request handlers */
    public class HTTPListener implements Runnable
        private ServerSocket serverSocket;
        public HTTPListener(int port)
            // Try to create a server socket on specified port
            try
                serverSocket = new ServerSocket(port, 0);
            catch (IOException ex)
                System.err.println("Oops!");
        public void run()
            while (!Thread.interrupted())
                try
                    // Listen on server socket until a request arrives
                    Socket s = serverSocket.accept();
                    // Create handler to service request
                    RequestHandler h = new RequestHandler(s);
                    new Thread(h).start();
                // Server socket closed when listening
                catch (SocketException ex)
                    Thread.currentThread().interrupt();
                // Failed to close socket or failure during server socket accept
                catch (IOException ex)
                    System.err.println("Failed to accept request");
            try
                serverSocket.close();
            catch (IOException ex)
                System.err.println("Hmpf...");
    /* Handler that prints out requests and always answers with status 200 */
    public class RequestHandler implements Runnable
        private Socket socket;
        public RequestHandler(Socket s)
            socket = s;
        public void run()
            System.out.println(">>> New request handler");
            try
                BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
                String str;
                while ((str = reader.readLine()) != null)
                    System.out.println(str);
                sendDummyReplyWithKeepAlive();
                reader.close();
                socket.close();
            catch (IOException ex)
                System.err.println("Crap, got an exception!");
    }When I run the server (which in reality has a little more to it) I never get more than one request printed for each ">>> New request handler", which is not surprising!
    Now, with keep-alive support I expect to get consecutive requests from the same client printed by the same handler instance. What I have to do (as I've understood from my readings) is to modify the while loop in the request handler that reads from the socket so that it spins until the connection is closed by the client (or a keep-alive timeout occurs) and blocks while there is nothing to read.
    Perhaps I'm being stupid now, but how do I actually do this?

    ejp wrote:
    and also an incorrect implementation of the timeout period. This code will still wait forever if no data arrives.You're right... actually I didn't mean to put that while loop there! What I meant was simply
    if (!reader.ready())
        wait(keepAliveTimeout);
    if (!reader.ready())
        break mainLoop;
    // If we get here there is a new request to read...and I agree that it's ugly, that's why I'm asking you guys for help!
    setSoTimeout() is of course a way to go... didn't think of that although I have kind of already added it to my code but with a different timeout. Thanks!
    Last question then is:
    does reader.readLine() block like reader.read(), or do I have to use the latter?
    I would test for myself I could, but at the moment I can't...

  • Too many SMTP connections kills server?

    I have a client who until recently had an old G4 server running 10.2.8. This server crashed regularly, usually when they sent out their email mailshot. I recently put in a new G5 running server 10.4.5 and all seemed well until they sent out the next mailshot, and hey presto the server went down.
    The mailing goes to thousands of opt-in subscribers; it is NOT sent by the OSX server; it's sent out by one of those web-based services. However, the reply address IS to the server and they get a lot of 'out of office' type returns as well as bounces.
    The server went down within 30 minutes of the mailing going out and from the log I estimate the server had about 40 open inbound SMTP connections running all at the same time, and the last 25 entries before the crash are all 'connect from <server-name>...' (different servers) and all within about a minute of each other.
    Bearing in mind this is a dual-core G5 I don't think the loading should be too much for it. The ADSL is slow (512k) but again I don't see why that should make it unstable. Is it possible that the mail server simply can't handle more than a certain number of simultaneous connections and if so is there a place in a config file where this can be limited to a manageable number?
    Justin

    Alex - totally agree with you about mailing list management. Keep in mind here this is a customer of mine, not me - and I have already suggested to them that such a large number of bounces means they should look harder at their list management.
    Also, I'm not on site right now so there's a limit to what I can do/see but I've inserted defaultprocesslimit = 10 into main.cf and restarted the server. Assuming the majority of returns have already happened I may not know if this has helped until the next mailshot goes out. I also suggested that setting some other address than their own for the return might be a good idea - even a hotmail address. But they don't like this because 'people would see it and think we're a small business' (they are a small business). The bottom line for them is that even if they're in the wrong about that they don't see why their shiny new server should crash because there's a lot of mail coming in.
    Both spam and virus filtering is on, and it's using two real-time blacklists.
    I will try and get some snapshots of the configs tonight.
    Finally, I don't know for certain sure that the server really was past the point of no return. It certainly was 'dead to the touch' but if the customer had been prepared to wait 15 minutes I suppose it might have 'got over it'. I doubt it though; I couldn't make it respond to Timbuktu, SSL, Server Admin, Mail (as a client) or afp. (I didn't try these all at once!) The only thing that worked was ping.
    Justin

Maybe you are looking for