Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
Disable socket.io read timeout (#494)
Browse files Browse the repository at this point in the history
Signed-off-by: John Pitman <[email protected]>
  • Loading branch information
jopit authored Dec 13, 2019
1 parent 761e5c9 commit 03bce75
Showing 1 changed file with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;

import org.eclipse.codewind.core.internal.CodewindApplication;
import org.eclipse.codewind.core.internal.CodewindApplicationFactory;
Expand Down Expand Up @@ -89,17 +90,21 @@ public CodewindSocket(CodewindConnection connection) throws URISyntaxException,
}
socketUri = uri;

OkHttpClient.Builder builder = new OkHttpClient.Builder();
if (connection.getAuthToken(false) != null) {
OkHttpClient okHttpClient = new OkHttpClient.Builder().hostnameVerifier(HttpUtil.hostnameVerifier).sslSocketFactory(HttpUtil.sslContext.getSocketFactory(), HttpUtil.trustManager).build();
IO.setDefaultOkHttpCallFactory(okHttpClient);
IO.setDefaultOkHttpWebSocketFactory(okHttpClient);
IO.Options opts = new IO.Options();
opts.callFactory = okHttpClient;
opts.webSocketFactory = okHttpClient;
socket = IO.socket(socketUri, opts);
} else {
socket = IO.socket(socketUri);
builder
.hostnameVerifier(HttpUtil.hostnameVerifier)
.sslSocketFactory(HttpUtil.sslContext.getSocketFactory(), HttpUtil.trustManager);
}
OkHttpClient okHttpClient = builder
.readTimeout(0L, TimeUnit.MILLISECONDS)
.build();
IO.setDefaultOkHttpCallFactory(okHttpClient);
IO.setDefaultOkHttpWebSocketFactory(okHttpClient);
IO.Options opts = new IO.Options();
opts.callFactory = okHttpClient;
opts.webSocketFactory = okHttpClient;
socket = IO.socket(socketUri, opts);

socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
@Override
Expand Down Expand Up @@ -159,8 +164,8 @@ public void call(Object... arg0) {
@Override
public void call(Object... arg0) {
if (arg0[0] instanceof Exception) {
// Exception e = (Exception) arg0[0];
// Logger.logError("SocketIO Error @ " + socketUri, e); //$NON-NLS-1$
Exception e = (Exception) arg0[0];
Logger.logError("SocketIO Error @ " + socketUri, e); //$NON-NLS-1$
}
}
})
Expand Down

0 comments on commit 03bce75

Please sign in to comment.