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

Enable ws connection timeout #159

Merged
merged 1 commit into from
Nov 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class JSONConfiguration {
public static final String PING_INTERVAL_PARAMETER = "PING_INTERVAL";
public static final String USERNAME_PARAMETER = "USERNAME";
public static final String PASSWORD_PARAMETER = "PASSWORD";
public static final String CONNECT_TIMEOUT_IN_MS_PARAMETER = "CONNECT_TIMEOUT_IN_MS";

private final HashMap<String, Object> parameters = new HashMap<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,11 @@ public void connect(String uri, RadioEvents events) {
httpHeaders.put("Authorization", "Basic " + new String(base64Credentials));
}

int connectTimeout =
this.configuration.getParameter(JSONConfiguration.CONNECT_TIMEOUT_IN_MS_PARAMETER, 0);

client =
new WebSocketClient(resource, draft, httpHeaders) {
new WebSocketClient(resource, draft, httpHeaders, connectTimeout) {
@Override
public void onOpen(ServerHandshake serverHandshake) {
logger.debug("On connection open (HTTP status: {})", serverHandshake.getHttpStatus());
Expand Down