You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Geir Harald Hansen (Created) (JIRA)" <ji...@apache.org> on 2012/01/08 12:09:39 UTC

[jira] [Created] (HTTPCORE-288) Change TCP_NODELAY and SO_KEEPALIVE on the fly

Change TCP_NODELAY and SO_KEEPALIVE on the fly
----------------------------------------------

                 Key: HTTPCORE-288
                 URL: https://issues.apache.org/jira/browse/HTTPCORE-288
             Project: HttpComponents HttpCore
          Issue Type: Improvement
          Components: HttpCore
    Affects Versions: 4.2-alpha2
            Reporter: Geir Harald Hansen
            Priority: Minor


Request:
HttpConnection#setTcpNoDelay() and setSocketKeepalive() methods to modify those socket settings on the fly like can be done with setSocketTimeout()

Motivation:
Set different socket options depending on the request to support different services on the same port. E.g. turn on TCP_NODELAY for requests to an AJAX-based unix shell, but turn it off for transferring large files. Turn on SO_KEEPALIVE and turn off socket timeout for long poll (comet) requests, but not for other requests.

Potential problem:
When using persistent connections it is easy to forget that these options survive to the next request. This situation exists with socket timeout already, though. You have to remember to set it back when sending a response if you don't want it for the next request. Perhaps a way to set timeout/nodelay/keepalive temporarily only for the current request is useful. Either way, I'd be happy to just be able to set nodelay and keepalive on the fly.


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] [Commented] (HTTPCORE-288) Change TCP_NODELAY and SO_KEEPALIVE on the fly

Posted by "Geir Harald Hansen (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-288?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13182270#comment-13182270 ] 

Geir Harald Hansen commented on HTTPCORE-288:
---------------------------------------------

I always just assumed it would work but have never tried it.

I googled around a bit. I could not find any info on Linux, but I found two webpages on Windows. According to http://msdn.microsoft.com/en-us/library/windows/desktop/ee470551%28v=vs.85%29.aspx running on Windows Vista or later you can set SO_KEEPALIVE before or after a call to connect() but not during an asynchronous connect() that has not yet completed. An example at http://msdn.microsoft.com/en-us/library/windows/desktop/ms740476%28v=vs.85%29.aspx shows binding a listening socket to a port and then modifying SO_KEEPALIVE afterwards.

The javadoc at http://docs.oracle.com/javase/6/docs/api/java/net/Socket.html doesn't say anything about it. It may be useful to also expose Socket#setTrafficClass - but the previous URL does warn that changing traffic class for an existing connection may not work, depending on the underlying TCP stack. I have no idea if the major platforms support such modification for active connections. Anyway, there is no such information for SO_KEEPALIVE and TCP_NODELAY.
                
> Change TCP_NODELAY and SO_KEEPALIVE on the fly
> ----------------------------------------------
>
>                 Key: HTTPCORE-288
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-288
>             Project: HttpComponents HttpCore
>          Issue Type: Improvement
>          Components: HttpCore
>    Affects Versions: 4.2-alpha2
>            Reporter: Geir Harald Hansen
>            Priority: Minor
>
> Request:
> HttpConnection#setTcpNoDelay() and setSocketKeepalive() methods to modify those socket settings on the fly like can be done with setSocketTimeout()
> Motivation:
> Set different socket options depending on the request to support different services on the same port. E.g. turn on TCP_NODELAY for requests to an AJAX-based unix shell, but turn it off for transferring large files. Turn on SO_KEEPALIVE and turn off socket timeout for long poll (comet) requests, but not for other requests.
> Potential problem:
> When using persistent connections it is easy to forget that these options survive to the next request. This situation exists with socket timeout already, though. You have to remember to set it back when sending a response if you don't want it for the next request. Perhaps a way to set timeout/nodelay/keepalive temporarily only for the current request is useful. Either way, I'd be happy to just be able to set nodelay and keepalive on the fly.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] [Updated] (HTTPCORE-288) Change TCP_NODELAY and SO_KEEPALIVE on the fly

Posted by "Oleg Kalnichevski (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HTTPCORE-288?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oleg Kalnichevski updated HTTPCORE-288:
---------------------------------------

      Component/s: HttpCore NIO
    Fix Version/s: Future

HttpConnection interface cannot be changed until 5.0 but what we can do in the meantime is adding those methods to the default HTTP connection implementation classes.

Oleg
                
> Change TCP_NODELAY and SO_KEEPALIVE on the fly
> ----------------------------------------------
>
>                 Key: HTTPCORE-288
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-288
>             Project: HttpComponents HttpCore
>          Issue Type: Improvement
>          Components: HttpCore, HttpCore NIO
>    Affects Versions: 4.2-alpha2
>            Reporter: Geir Harald Hansen
>            Priority: Minor
>             Fix For: Future
>
>
> Request:
> HttpConnection#setTcpNoDelay() and setSocketKeepalive() methods to modify those socket settings on the fly like can be done with setSocketTimeout()
> Motivation:
> Set different socket options depending on the request to support different services on the same port. E.g. turn on TCP_NODELAY for requests to an AJAX-based unix shell, but turn it off for transferring large files. Turn on SO_KEEPALIVE and turn off socket timeout for long poll (comet) requests, but not for other requests.
> Potential problem:
> When using persistent connections it is easy to forget that these options survive to the next request. This situation exists with socket timeout already, though. You have to remember to set it back when sending a response if you don't want it for the next request. Perhaps a way to set timeout/nodelay/keepalive temporarily only for the current request is useful. Either way, I'd be happy to just be able to set nodelay and keepalive on the fly.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] [Commented] (HTTPCORE-288) Change TCP_NODELAY and SO_KEEPALIVE on the fly

Posted by "Oleg Kalnichevski (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-288?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13182252#comment-13182252 ] 

Oleg Kalnichevski commented on HTTPCORE-288:
--------------------------------------------

For some reason I always thought TCP_NODELAY and SO_KEEPALIVE only could be applied to newly created sockets only. Are you sure they can be changed on an already initialized socket?

Oleg
                
> Change TCP_NODELAY and SO_KEEPALIVE on the fly
> ----------------------------------------------
>
>                 Key: HTTPCORE-288
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-288
>             Project: HttpComponents HttpCore
>          Issue Type: Improvement
>          Components: HttpCore
>    Affects Versions: 4.2-alpha2
>            Reporter: Geir Harald Hansen
>            Priority: Minor
>
> Request:
> HttpConnection#setTcpNoDelay() and setSocketKeepalive() methods to modify those socket settings on the fly like can be done with setSocketTimeout()
> Motivation:
> Set different socket options depending on the request to support different services on the same port. E.g. turn on TCP_NODELAY for requests to an AJAX-based unix shell, but turn it off for transferring large files. Turn on SO_KEEPALIVE and turn off socket timeout for long poll (comet) requests, but not for other requests.
> Potential problem:
> When using persistent connections it is easy to forget that these options survive to the next request. This situation exists with socket timeout already, though. You have to remember to set it back when sending a response if you don't want it for the next request. Perhaps a way to set timeout/nodelay/keepalive temporarily only for the current request is useful. Either way, I'd be happy to just be able to set nodelay and keepalive on the fly.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] [Resolved] (HTTPCORE-288) Change TCP_NODELAY and SO_KEEPALIVE on the fly

Posted by "Oleg Kalnichevski (Resolved) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HTTPCORE-288?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oleg Kalnichevski resolved HTTPCORE-288.
----------------------------------------

       Resolution: Fixed
    Fix Version/s:     (was: Future)
                   4.2-beta2

HTTPCORE-295 provided a means of getting access to the underlying socket of non-blocking connections thus allowing modification of socket settings at execution time. It is quite a hack but it is all we can do without breaking the API.

Oleg 
                
> Change TCP_NODELAY and SO_KEEPALIVE on the fly
> ----------------------------------------------
>
>                 Key: HTTPCORE-288
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-288
>             Project: HttpComponents HttpCore
>          Issue Type: Improvement
>          Components: HttpCore, HttpCore NIO
>    Affects Versions: 4.2-alpha2
>            Reporter: Geir Harald Hansen
>            Priority: Minor
>             Fix For: 4.2-beta2
>
>
> Request:
> HttpConnection#setTcpNoDelay() and setSocketKeepalive() methods to modify those socket settings on the fly like can be done with setSocketTimeout()
> Motivation:
> Set different socket options depending on the request to support different services on the same port. E.g. turn on TCP_NODELAY for requests to an AJAX-based unix shell, but turn it off for transferring large files. Turn on SO_KEEPALIVE and turn off socket timeout for long poll (comet) requests, but not for other requests.
> Potential problem:
> When using persistent connections it is easy to forget that these options survive to the next request. This situation exists with socket timeout already, though. You have to remember to set it back when sending a response if you don't want it for the next request. Perhaps a way to set timeout/nodelay/keepalive temporarily only for the current request is useful. Either way, I'd be happy to just be able to set nodelay and keepalive on the fly.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org