Reduced the connection timeout from the default of 10 seconds to 2 seconds

This commit is contained in:
Nelson R. Perez 2018-10-12 18:36:11 -05:00
parent d75957e5d1
commit d25a1f3fa0

View file

@ -2,6 +2,7 @@ package cy.agorise.graphenej.api.android;
import android.app.Service; import android.app.Service;
import android.content.Intent; import android.content.Intent;
import java.util.concurrent.TimeUnit;
import android.os.Binder; import android.os.Binder;
import android.os.Handler; import android.os.Handler;
import android.os.IBinder; import android.os.IBinder;
@ -168,7 +169,10 @@ public class NetworkService extends Service {
* Actually establishes a connection from this Service to one of the full nodes. * Actually establishes a connection from this Service to one of the full nodes.
*/ */
public void connect(){ public void connect(){
OkHttpClient client = new OkHttpClient(); OkHttpClient client = new OkHttpClient
.Builder()
.connectTimeout(2, TimeUnit.SECONDS)
.build();
mSelectedNode = nodeProvider.getBestNode(); mSelectedNode = nodeProvider.getBestNode();
Log.v(TAG,"connect.url: "+ mSelectedNode.getUrl()); Log.v(TAG,"connect.url: "+ mSelectedNode.getUrl());
Request request = new Request.Builder().url(mSelectedNode.getUrl()).build(); Request request = new Request.Builder().url(mSelectedNode.getUrl()).build();