Skip to content

Commit 050729b

Browse files
author
Stephen Asbury
authored
Merge pull request #242 from nats-io/v2.5.1
V2.5.1
2 parents 765af9b + 765082a commit 050729b

File tree

7 files changed

+55
-11
lines changed

7 files changed

+55
-11
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11

22
# Change Log
33

4+
## Version 2.5.1
5+
6+
* [FIXED] - #239 - cleaned up extra code after SSL connect failure
7+
* [FIXED] - #240 - removed stack trace that was left from debugging
8+
* [FIXED] - #241 - changed method used to create an ssl socket to allow support for conscrypt/wildfly native libraries
9+
* [ADDED] - conscrypt flag to natsautobench to allow testing with native library, requires Jar in class path
10+
411
## Version 2.5.0
512

613
* [CHANGED] added back pressure to message queue on publish, this may effect behavior of multi-threaded publishers so moving minor version

README.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,18 @@ Version 2.5.0 adds some back pressure to publish calls to alleviate issues when
2424

2525
Previous versions are still available in the repo.
2626

27+
### SSL/TLS Performance
28+
29+
After recent tests we realized that TLS performance is lower than we would like. After researching the problem and possible solutions we came to a few conclusions:
30+
31+
* TLS performance for the native JDK has not be historically great
32+
* TLS performance is better in JDK12 than JDK8
33+
* A small fix to the library in 2.5.1 allows the use of https://github.com/google/conscrypt and https://github.com/wildfly/wildfly-openssl, conscrypt provides the best performance in our tests
34+
* TLS still comes at a price (1gb/s vs 4gb/s in some tests), but using the JNI libraries can result in a 10x boost in our testing
35+
* If TLS performance is reasonable for your application we recommend using the j2se implementation for simplicity
36+
37+
To use conscrypt or wildfly, you will need to add the appropriate jars to your class path and create an SSL context manually. This context can be passed to the Options used when creating a connection. The NATSAutoBench example provides a conscrypt flag which can be used to try out the library, manually including the jar is required.
38+
2739
### UTF-8 Subjects
2840

2941
The client protocol spec doesn't explicitly state the encoding on subjects. Some clients use ASCII and some use UTF-8 which matches ASCII for a-Z and 0-9. Until 2.1.2 the 2.0+ version of the Java client used ASCII for performance reasons. As of 2.1.2 you can choose to support UTF-8 subjects via the Options. Keep in mind that there is a small performance penalty for UTF-8 encoding and decoding in benchmarks, but depending on your application this cost may be negligible. Also, keep in mind that not all clients support UTF-8 and test accordingly.
@@ -40,9 +52,9 @@ The java-nats client is provided in a single jar file, with a single external de
4052

4153
### Downloading the Jar
4254

43-
You can download the latest jar at [https://search.maven.org/remotecontent?filepath=io/nats/jnats/2.5.0/jnats-2.5.0.jar](https://search.maven.org/remotecontent?filepath=io/nats/jnats/2.5.0/jnats-2.5.0.jar).
55+
You can download the latest jar at [https://search.maven.org/remotecontent?filepath=io/nats/jnats/2.5.1/jnats-2.5.1.jar](https://search.maven.org/remotecontent?filepath=io/nats/jnats/2.5.1/jnats-2.5.1.jar).
4456

45-
The examples are available at [https://search.maven.org/remotecontent?filepath=io/nats/jnats/2.5.0/jnats-2.5.0-examples.jar](https://search.maven.org/remotecontent?filepath=io/nats/jnats/2.5.0/jnats-2.5.0-examples.jar).
57+
The examples are available at [https://search.maven.org/remotecontent?filepath=io/nats/jnats/2.5.1/jnats-2.5.1-examples.jar](https://search.maven.org/remotecontent?filepath=io/nats/jnats/2.5.1/jnats-2.5.1-examples.jar).
4658

4759
To use NKeys, you will need the ed25519 library, which can be downloaded at [https://repo1.maven.org/maven2/net/i2p/crypto/eddsa/0.3.0/eddsa-0.3.0.jar](https://repo1.maven.org/maven2/net/i2p/crypto/eddsa/0.3.0/eddsa-0.3.0.jar).
4860

@@ -52,7 +64,7 @@ The NATS client is available in the Maven central repository, and can be importe
5264

5365
```groovy
5466
dependencies {
55-
implementation 'io.nats:jnats:2.5.0'
67+
implementation 'io.nats:jnats:2.5.1'
5668
}
5769
```
5870

@@ -78,7 +90,7 @@ The NATS client is available on the Maven central repository, and can be importe
7890
<dependency>
7991
<groupId>io.nats</groupId>
8092
<artifactId>jnats</artifactId>
81-
<version>2.5.0</version>
93+
<version>2.5.1</version>
8294
</dependency>
8395
```
8496

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ plugins {
1414
// Be sure to update Nats.java with the latest version, the change log and the package-info.java
1515
def versionMajor = 2
1616
def versionMinor = 5
17-
def versionPatch = 0
17+
def versionPatch = 1
1818
def versionModifier = ""
19-
def jarVersion = "2.5.0"
19+
def jarVersion = "2.5.1"
2020
def branch = System.getenv("TRAVIS_BRANCH");
2121

2222
def getVersionName = { ->

src/examples/java/io/nats/examples/autobench/NatsAutoBench.java

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@
1313

1414
package io.nats.examples.autobench;
1515

16+
import java.security.Provider;
17+
import java.security.Security;
1618
import java.time.Duration;
1719
import java.util.ArrayList;
1820
import java.util.List;
1921

22+
import javax.net.ssl.SSLContext;
23+
2024
import io.nats.client.Options;
2125

2226
/**
@@ -36,6 +40,7 @@ public class NatsAutoBench {
3640
public static void main(String args[]) {
3741
String server = Options.DEFAULT_URL;
3842
boolean utf8 = false;
43+
boolean conscrypt = false;
3944
int baseMsgs = 100_000;
4045
int latencyMsgs = 5_000;
4146
long maxSize = 8*1024;
@@ -44,10 +49,12 @@ public static void main(String args[]) {
4449
for (String s : args) {
4550
if (s.equals("utf8")) {
4651
utf8 = true;
47-
}else if (s.equals("med")) {
52+
} else if (s.equals("conscrypt")) {
53+
conscrypt = true;
54+
} else if (s.equals("med")) {
4855
baseMsgs = 50_000;
4956
latencyMsgs = 2_500;
50-
} else if (s.equals("small")) {
57+
} else if (s.equals("small")) {
5158
baseMsgs = 5_000;
5259
latencyMsgs = 250;
5360
maxSize = 1024;
@@ -80,6 +87,24 @@ public static void main(String args[]) {
8087
System.out.printf("Enabling UTF-8 subjects\n");
8188
builder.supportUTF8Subjects();
8289
}
90+
91+
/**
92+
* The conscrypt flag is provided for testing with the conscrypt jar. Using it through reflection is
93+
* deprecated but allows the library to ship without a dependency. Using conscrypt should only require the
94+
* jar plus the flag. For example, to run after building locally and using the test cert files:
95+
* java -cp ./build/libs/jnats-2.5.1-SNAPSHOT-examples.jar:./build/libs/jnats-2.5.1-SNAPSHOT-fat.jar:<path to conscrypt.jar> \
96+
* -Djavax.net.ssl.keyStore=src/test/resources/keystore.jks -Djavax.net.ssl.keyStorePassword=password \
97+
* -Djavax.net.ssl.trustStore=src/test/resources/cacerts -Djavax.net.ssl.trustStorePassword=password \
98+
* io.nats.examples.autobench.NatsAutoBench tls://localhost:4443 med conscrypt
99+
*/
100+
if (conscrypt) {
101+
Provider provider = (Provider) Class.forName("org.conscrypt.OpenSSLProvider").newInstance();
102+
Security.insertProviderAt(provider, 1);
103+
}
104+
105+
if (server.startsWith("tls")) {
106+
System.out.println("Security Provider - "+ SSLContext.getDefault().getProvider().getInfo());
107+
}
83108

84109
Options connectOptions = builder.build();
85110
List<AutoBenchmark> tests = buildTestList(baseMsgs, latencyMsgs, maxSize);

src/main/java/io/nats/client/Nats.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public class Nats {
7272
/**
7373
* Current version of the library - {@value #CLIENT_VERSION}
7474
*/
75-
public static final String CLIENT_VERSION = "2.5.0";
75+
public static final String CLIENT_VERSION = "2.5.1";
7676

7777
/**
7878
* Current language of the library - {@value #CLIENT_LANGUAGE}

src/main/java/io/nats/client/impl/NatsConnection.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,6 @@ void sendConnect(String serverURI) throws IOException {
10101010

10111011
queueInternalOutgoing(msg);
10121012
} catch (Exception exp) {
1013-
exp.printStackTrace();
10141013
throw new IOException("Error sending connect string", exp);
10151014
}
10161015
}

src/main/java/io/nats/client/impl/SocketDataPort.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public void upgradeToSecure() throws IOException {
7575
SSLSocketFactory factory = context.getSocketFactory();
7676
Duration timeout = options.getConnectionTimeout();
7777

78-
this.sslSocket = (SSLSocket) factory.createSocket(socket, null, true);
78+
this.sslSocket = (SSLSocket) factory.createSocket(socket, this.host, this.port, true);
7979
this.sslSocket.setUseClientMode(true);
8080

8181
final CompletableFuture<Void> waitForHandshake = new CompletableFuture<>();
@@ -90,6 +90,7 @@ public void upgradeToSecure() throws IOException {
9090
waitForHandshake.get(timeout.toNanos(), TimeUnit.NANOSECONDS);
9191
} catch (Exception ex) {
9292
this.connection.handleCommunicationIssue(ex);
93+
return;
9394
}
9495

9596
in = sslSocket.getInputStream();

0 commit comments

Comments
 (0)