Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
85b4999
Fix multiple issues related to reconnect
PhilipRoman Nov 1, 2023
8834112
Merge pull request #1367 from TooTallNate/reconnect-fix
PhilipRoman Nov 29, 2023
43c9693
Update changelog for 1.5.5
marci4 Dec 18, 2023
fe637a8
Merge pull request #1377 from marci4/1.5.5-update_changelog
marci4 Dec 18, 2023
4a6e1c4
Increase version to 1.5.6
marci4 Dec 18, 2023
a1ab3dc
Merge pull request #1378 from marci4/1.5.5_increase_version
marci4 Dec 18, 2023
1ecae0e
Replace <tt> with <code> in javadocs
PhilipRoman Jan 13, 2024
9dce7a8
Merge pull request #1385 from TooTallNate/javadoc-tt-fix
marci4 Jan 15, 2024
d4365d4
Retrieve default SSL socket factory to reconcile the configuration wi…
Jan 16, 2024
de7b8b2
Merge pull request #1387 from pavel-treutner/issue-1382
marci4 Jan 30, 2024
c717bc7
Provide way to start the client/server as daemons
newk5 Nov 27, 2021
9f53da4
Merge pull request #1391 from TooTallNate/daemon
marci4 Feb 4, 2024
4bdfe1f
Release 1.5.6
marci4 Feb 6, 2024
ae78d38
Merge pull request #1394 from marci4/1.5.5_release
marci4 Feb 6, 2024
765932a
Increase version to 1.5.7
marci4 Feb 6, 2024
6910229
Merge pull request #1395 from marci4/1.5.6_increase_version
marci4 Feb 6, 2024
f7d51a8
Explicitly close the socket when resetting the client if the connecti…
Feb 16, 2024
d8eb0f8
Ensure the socket is not null when attempting to close it.
Feb 21, 2024
aa84b39
Merge pull request #1399 from ysi-camerona/ISSUE-1397
PhilipRoman Feb 24, 2024
acd03d0
Add test for connectBlocking cleanup (#1399)
PhilipRoman Feb 24, 2024
1f842a6
Add timeout to CI test
PhilipRoman Apr 15, 2024
f625a1a
Allow setting custom TCP receive buffer size
PhilipRoman Apr 14, 2024
7e47e4d
Merge pull request #1407 from TooTallNate/receive-buffer-size
marci4 Apr 27, 2024
c793f34
Merge pull request #1401 from TooTallNate/connect_blocking_cleanup_test
PhilipRoman Apr 27, 2024
ad3d043
Fix WebSocketServer sometimes missing GET request
robert-s-ubi Jun 8, 2024
cd08f83
Merge pull request #1419 from ubitricity/fix_issue_1418_websocketserv…
PhilipRoman Jun 10, 2024
dd07648
Release 1.5.7
marci4 Jul 8, 2024
d866754
Merge pull request #1432 from marci4/1.5.7_release
marci4 Jul 8, 2024
202d7a4
Increase version to 1.5.8
marci4 Jul 8, 2024
4aef466
Merge pull request #1433 from marci4/1.5.7_increase_version
marci4 Jul 8, 2024
01e1a40
Drop support for Java 1.7
marci4 Jul 12, 2024
c4bf44e
Merge pull request #1435 from marci4/feature/drop_java1.7
marci4 Jul 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:

Test:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
Expand Down
45 changes: 45 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,50 @@
# Change log

###############################################################################
## Version Release 1.5.7 (2024/07/08)

#### Breaking Changes

* [PR 1399](https://github.com/TooTallNate/Java-WebSocket/pull/1399) - Have connectBlocking clean up after a timeout

#### Bugs Fixed

* [PR 1419](https://github.com/TooTallNate/Java-WebSocket/pull/1419) - Fix issue #1418: WebSocketServer sometimes misses GET request after SSL handshake

#### New Features

* [PR 1407](https://github.com/TooTallNate/Java-WebSocket/pull/1407) - Allow setting custom TCP receive buffer size
* [PR 1399](https://github.com/TooTallNate/Java-WebSocket/pull/1399) - Have connectBlocking clean up after a timeout

In this release 0 issues and 4 pull requests were closed.

###############################################################################
## Version Release 1.5.6 (2024/02/06)

#### Bugs Fixed

* [Issue 1382](https://github.com/TooTallNate/Java-WebSocket/issues/1382) - WebSocketClient.upgradeSocketToSSL is enforcing TLS 1.2 ([PR 1387](https://github.com/TooTallNate/Java-WebSocket/pull/1387))
* [PR 1387](https://github.com/TooTallNate/Java-WebSocket/pull/1387) - Retrieve default SSL socket factory

#### New Features

* [Issue 1390](https://github.com/TooTallNate/Java-WebSocket/issues/1390) - Thread created by NamedThreadFactory should be a daemon ([PR 1391](https://github.com/TooTallNate/Java-WebSocket/pull/1391))
* [PR 1391](https://github.com/TooTallNate/Java-WebSocket/pull/1391) - Provide way to start the client/server as daemons

In this release 2 issues and 2 pull requests were closed.

###############################################################################

## Version Release 1.5.5 (2023/12/18)

#### Bugs Fixed

* [Issue 1365](https://github.com/TooTallNate/Java-WebSocket/issues/1365) - Hang on reconnectBlocking
* [Issue 1364](https://github.com/TooTallNate/Java-WebSocket/issues/1364) - NPE during reconnect ([PR 1367](https://github.com/TooTallNate/Java-WebSocket/pull/1367))
* [PR 1367](https://github.com/TooTallNate/Java-WebSocket/pull/1367) - Fix multiple issues related to reconnect

In this release 2 issues and 1 pull request were closed.

###############################################################################

## Version Release 1.5.4 (2023/07/20)
Expand Down
8 changes: 4 additions & 4 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ To use maven add this dependency to your pom.xml:
<dependency>
<groupId>org.java-websocket</groupId>
<artifactId>Java-WebSocket</artifactId>
<version>1.5.4</version>
<version>1.5.7</version>
</dependency>
```

Expand All @@ -41,11 +41,11 @@ mavenCentral()
```
Then you can just add the latest version to your build.
```xml
compile "org.java-websocket:Java-WebSocket:1.5.4"
compile "org.java-websocket:Java-WebSocket:1.5.7"
```
Or this option if you use gradle 7.0 and above.
```xml
implementation 'org.java-websocket:Java-WebSocket:1.5.4'
implementation 'org.java-websocket:Java-WebSocket:1.5.7'
```

#### Logging
Expand Down Expand Up @@ -114,7 +114,7 @@ Minimum Required JDK

`Java-WebSocket` is known to work with:

* Java 1.7 and higher
* Java 8 and higher

Other JRE implementations may work as well, but haven't been tested.

Expand Down
13 changes: 6 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ repositories {
}

group = 'org.java-websocket'
version = '1.5.4-SNAPSHOT'
sourceCompatibility = 1.7
targetCompatibility = 1.7
version = '1.6.0-SNAPSHOT'
sourceCompatibility = 1.8
targetCompatibility = 1.8

compileJava {
options.compilerArgs += ['-encoding', 'UTF-8']
Expand All @@ -35,8 +35,7 @@ publishing {
}

dependencies {
implementation group: 'org.slf4j', name: 'slf4j-api', version: '2.0.6'
testImplementation group: 'org.slf4j', name: 'slf4j-simple', version: '2.0.6'
testImplementation group: 'junit', name: 'junit', version: '4.12'
testImplementation group: 'org.json', name: 'json', version: '20180813'
implementation group: 'org.slf4j', name: 'slf4j-api', version: '2.0.13'
testImplementation group: 'org.slf4j', name: 'slf4j-simple', version: '2.0.13'
testImplementation group: 'junit', name: 'junit', version: '4.13.1'
}
18 changes: 3 additions & 15 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@
<groupId>org.java-websocket</groupId>
<artifactId>Java-WebSocket</artifactId>
<packaging>jar</packaging>
<version>1.5.5-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
<name>Java-WebSocket</name>
<description>A barebones WebSocket client and server implementation written 100% in Java</description>
<url>https://github.com/TooTallNate/Java-WebSocket</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<slf4j.version>2.0.6</slf4j.version>
<slf4j.version>2.0.13</slf4j.version>

<!-- Test dependencies versions -->
<junit.version>4.12</junit.version>
<org.json.version>20180813</org.json.version>
<junit.version>4.13.1</junit.version>

<!-- Maven plugin versions -->
<bnd.maven.plugin.version>6.4.0</bnd.maven.plugin.version>
Expand Down Expand Up @@ -63,12 +62,6 @@
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>${org.json.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
Expand Down Expand Up @@ -299,11 +292,6 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<developers>
<developer>
Expand Down
67 changes: 66 additions & 1 deletion src/main/java/org/java_websocket/AbstractWebSocket.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,30 @@ public abstract class AbstractWebSocket extends WebSocketAdapter {
*/
private boolean websocketRunning = false;

/**
* Attribute to start internal threads as daemon
*
* @since 1.5.6
*/
private boolean daemon = false;

/**
* Attribute to sync on
*/
private final Object syncConnectionLost = new Object();

/**
* TCP receive buffer size that will be used for sockets (zero means use system default)
*
* @since 1.5.7
*/
private int receiveBufferSize = 0;

/**
* Used for internal buffer allocations when the socket buffer size is not specified.
*/
protected static int DEFAULT_READ_BUFFER_SIZE = 65536;

/**
* Get the interval checking for lost connections Default is 60 seconds
*
Expand Down Expand Up @@ -182,7 +201,7 @@ protected void startConnectionLostTimer() {
private void restartConnectionLostTimer() {
cancelConnectionLostTimer();
connectionLostCheckerService = Executors
.newSingleThreadScheduledExecutor(new NamedThreadFactory("connectionLostChecker"));
.newSingleThreadScheduledExecutor(new NamedThreadFactory("connectionLostChecker", daemon));
Runnable connectionLostChecker = new Runnable() {

/**
Expand Down Expand Up @@ -308,4 +327,50 @@ public void setReuseAddr(boolean reuseAddr) {
this.reuseAddr = reuseAddr;
}


/**
* Getter for daemon
*
* @return whether internal threads are spawned in daemon mode
* @since 1.5.6
*/
public boolean isDaemon() {
return daemon;
}

/**
* Setter for daemon
* <p>
* Controls whether or not internal threads are spawned in daemon mode
*
* @since 1.5.6
*/
public void setDaemon(boolean daemon) {
this.daemon = daemon;
}

/**
* Returns the TCP receive buffer size that will be used for sockets (or zero, if not explicitly set).
* @see java.net.Socket#setReceiveBufferSize(int)
*
* @since 1.5.7
*/
public int getReceiveBufferSize() {
return receiveBufferSize;
}

/**
* Sets the TCP receive buffer size that will be used for sockets.
* If this is not explicitly set (or set to zero), the system default is used.
* @see java.net.Socket#setReceiveBufferSize(int)
*
* @since 1.5.7
*/
public void setReceiveBufferSize(int receiveBufferSize) {
if (receiveBufferSize < 0) {
throw new IllegalArgumentException("buffer size < 0");
}
this.receiveBufferSize = receiveBufferSize;
}

}
12 changes: 6 additions & 6 deletions src/main/java/org/java_websocket/SSLSocketChannel2.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public SSLSocketChannel2(SocketChannel channel, SSLEngine sslEngine, ExecutorSer
createBuffers(sslEngine.getSession());
// kick off handshake
socketChannel.write(wrap(emptybuffer));// initializes res
processHandshake();
processHandshake(false);
}

private void consumeFutureUninterruptible(Future<?> f) {
Expand All @@ -148,7 +148,7 @@ private void consumeFutureUninterruptible(Future<?> f) {
* This method will do whatever necessary to process the sslEngine handshake. Thats why it's
* called both from the {@link #read(ByteBuffer)} and {@link #write(ByteBuffer)}
**/
private synchronized void processHandshake() throws IOException {
private synchronized void processHandshake(boolean isReading) throws IOException {
if (sslEngine.getHandshakeStatus() == HandshakeStatus.NOT_HANDSHAKING) {
return; // since this may be called either from a reading or a writing thread and because this method is synchronized it is necessary to double check if we are still handshaking.
}
Expand All @@ -167,7 +167,7 @@ private synchronized void processHandshake() throws IOException {
}
}

if (sslEngine.getHandshakeStatus() == SSLEngineResult.HandshakeStatus.NEED_UNWRAP) {
if (isReading && sslEngine.getHandshakeStatus() == SSLEngineResult.HandshakeStatus.NEED_UNWRAP) {
if (!isBlocking() || readEngineResult.getStatus() == Status.BUFFER_UNDERFLOW) {
inCrypt.compact();
int read = socketChannel.read(inCrypt);
Expand Down Expand Up @@ -273,7 +273,7 @@ protected void createBuffers(SSLSession session) {

public int write(ByteBuffer src) throws IOException {
if (!isHandShakeComplete()) {
processHandshake();
processHandshake(false);
return 0;
}
// assert(bufferallocations > 1); // see #190
Expand Down Expand Up @@ -303,10 +303,10 @@ public int read(ByteBuffer dst) throws IOException {
if (!isHandShakeComplete()) {
if (isBlocking()) {
while (!isHandShakeComplete()) {
processHandshake();
processHandshake(true);
}
} else {
processHandshake();
processHandshake(true);
if (!isHandShakeComplete()) {
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/java_websocket/WebSocketAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void onWebsocketPong(WebSocket conn, Framedata f) {
* Default implementation for onPreparePing, returns a (cached) PingFrame that has no application
* data.
*
* @param conn The <tt>WebSocket</tt> connection from which the ping frame will be sent.
* @param conn The <code>WebSocket</code> connection from which the ping frame will be sent.
* @return PingFrame to be sent.
* @see org.java_websocket.WebSocketListener#onPreparePing(WebSocket)
*/
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/org/java_websocket/WebSocketImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,6 @@ public class WebSocketImpl implements WebSocket {
*/
public static final int DEFAULT_WSS_PORT = 443;

/**
* Initial buffer size
*/
public static final int RCVBUF = 16384;

/**
* Logger instance
*
Expand Down
Loading