Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fake getTcpNoDelay for SSL sockets to work #31

Closed
CCob opened this issue Jan 28, 2013 · 3 comments
Closed

Fake getTcpNoDelay for SSL sockets to work #31

CCob opened this issue Jan 28, 2013 · 3 comments
Labels

Comments

@CCob
Copy link
Collaborator

CCob commented Jan 28, 2013

I've come across one use case (in a browser running an applet) that the SSL socket implementation is checking the property getTcpNoDelay on the NetSocketUDT. At the moment this currently throws an RuntimeException that it's unsupported.

Caused by: java.lang.RuntimeException: feature not available
    at com.barchart.udt.net.NetSocketUDT.getTcpNoDelay(NetSocketUDT.java:168)
    at sun.security.ssl.BaseSSLSocketImpl.getTcpNoDelay(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.writeRecordInternal(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.writeRecord(Unknown Source)

We should either return a true or false. This is a snippet from the OpenJDK implementation of the SSL socket.

        if (holdRecord) {
            // If we were requested to delay the record due to possibility
            // of Nagle's being active when finally got to writing, and
            // it's actually not, we don't really need to delay it.
            if (getTcpNoDelay()) {
                holdRecord = false;
            } else {
                // We need to hold the record, so let's provide
                // a per-socket place to do it.
                if (heldRecordBuffer == null) {
                    // Likely only need 37 bytes.
                    heldRecordBuffer = new ByteArrayOutputStream(40);
                }
            }
        }

Since UDT doesn't have a Nagle algorithm or similar, my gut instinct would be to return false instead of a RuntimeException. At least this should satisfy SSL. Whats your feeling on this?

@CCob
Copy link
Collaborator Author

CCob commented Jan 28, 2013

I found out why it's doing it in the applet vs my test environment. My browser environment is HotSpot 1.7, vs my IDE environment of 1.6. It seems they have changed SSL in 1.7 to look at the Nagle info on the Socket.

@carrot-garden
Copy link
Contributor

  1. "fake getTcpNoDelay" sounds good
  2. while you are at it, you may want to fake all else which currently blows up with "feature not available"
  3. consider using log.debug() instead of exception so at least we know what is going on with missing features

@CCob
Copy link
Collaborator Author

CCob commented Jan 28, 2013

I've done a pull request which puts in some sensible values for getters, but throw UnsupportedOperationException on setters, since an application may expect specific behavior to happen with these, so at least they will get a heads up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant