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

develop
Nelson R. Perez 2018-10-12 18:36:11 -05:00
parent d75957e5d1
commit d25a1f3fa0
1 changed files with 5 additions and 1 deletions

View File

@ -2,6 +2,7 @@ package cy.agorise.graphenej.api.android;
import android.app.Service;
import android.content.Intent;
import java.util.concurrent.TimeUnit;
import android.os.Binder;
import android.os.Handler;
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.
*/
public void connect(){
OkHttpClient client = new OkHttpClient();
OkHttpClient client = new OkHttpClient
.Builder()
.connectTimeout(2, TimeUnit.SECONDS)
.build();
mSelectedNode = nodeProvider.getBestNode();
Log.v(TAG,"connect.url: "+ mSelectedNode.getUrl());
Request request = new Request.Builder().url(mSelectedNode.getUrl()).build();