I am using okhttp3 as a networking library and Node-mongo as a back-end service.Sometimes when my app starts it shows timeout exception and when I close app and start it again then it fetches data from the server.There is no error in app but I want to know why timeout exception is showing.
Below is my code in which I am showing data in listview.
MainActivity.java
public class Activity2 extends AppCompatActivity {
ListView listView;
List<Data> places;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_2);
    listView  = findViewById(R.id.listView);
    places = new ArrayList<>();
    final ProgressDialog prg = new ProgressDialog(Activity2.this);
    prg.setMessage("Loading...");
    prg.show();
    Log.d("OnCreate","Oncreate started");
    OkHttpClient client = new OkHttpClient();
    Request request = new Request.Builder().url("https://tiffino.herokuapp.com/test").build();
    client.newCall(request).enqueue(new Callback() {
        @Override
        public void onFailure(Call call, final IOException e) {
            prg.dismiss();
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    Toast.makeText(getApplicationContext(),""+e.getMessage(),Toast.LENGTH_SHORT).show();
                }
            });
        }
        @Override
        public void onResponse(Call call, final Response response) throws IOException {
            prg.dismiss();
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    try {
                        JSONArray arr = new JSONArray(response.body().string());
                        for(int i = 0;i < arr.length();i++){
                            JSONObject obj = arr.getJSONObject(i);
                            String str1 = obj.getString("Name");
                            Data data = new Data(str1);
                            places.add(data);
                        }
                        PlacesAdapter adapter=  new PlacesAdapter(places,getApplicationContext());
                        listView.setAdapter(adapter);
                    } catch (JSONException e) {
                        e.printStackTrace();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            });
        }
    });
   }
} 
PlacesAdapter.java
public class PlacesAdapter extends ArrayAdapter<Data> {
private List<Data>  places;
private Context ctx;
public PlacesAdapter( List<Data> places, Context ctx) {
    super(ctx,R.layout.places_row,places);
    this.places = places;
    this.ctx = ctx;
}
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
    LayoutInflater inflater = LayoutInflater.from(ctx);
    View listView = inflater.inflate(R.layout.places_row,null,true);
    TextView txt = listView.findViewById(R.id.txt);
    Data data = places.get(position);
    txt.setText(data.getPlace());
    return listView;
  }
}
How can I solve this?