Skip to content

Commit 8c5766a

Browse files
authored
Merge pull request #1465 from Yuval-Roth/master
reconnectBlocking overload that supports timeout
2 parents c69b298 + 3d8b96f commit 8c5766a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/main/java/org/java_websocket/client/WebSocketClient.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,21 @@ public boolean reconnectBlocking() throws InterruptedException {
327327
return connectBlocking();
328328
}
329329

330+
/**
331+
* Same as <code>reconnect</code> but blocks with a timeout until the websocket connected or failed
332+
* to do so.<br>
333+
*
334+
* @param timeout The connect timeout
335+
* @param timeUnit The timeout time unit
336+
* @return Returns whether it succeeded or not.
337+
* @throws InterruptedException Thrown when the threads get interrupted
338+
* @since 1.6.1
339+
*/
340+
public boolean reconnectBlocking(long timeout, TimeUnit timeUnit) throws InterruptedException {
341+
reset();
342+
return connectBlocking(timeout, timeUnit);
343+
}
344+
330345
/**
331346
* Reset everything relevant to allow a reconnect
332347
*

0 commit comments

Comments
 (0)