I am working on my own project testing (Java) on a physical device with Android 4.4.2. My OkHttpClient website is connecting, but time is running out after 10 seconds, this is what I am trying to use to change the timeout.
OkHttpClient client = new OkHttpClient(); client.setReadTimeout(0, TimeUnit.MILLISECONDS);
but it says Cannot resolve method setReadTimeout(int, java.util.concurrent.TimeUnit)
This is my import:
import android.util.Log; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; import okhttp3.ResponseBody; import okhttp3.ws.WebSocket; import okhttp3.ws.WebSocketCall; import okhttp3.ws.WebSocketListener; import okio.Buffer; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import java.io.IOException; import java.util.*; import java.util.concurrent.TimeUnit;
and in my gradle file I have compile 'com.squareup.okhttp3:okhttp-ws:3.4.1'
source share