Thursday 11 March 2021

Android Volley: Why does the second request of these two requests fail with a timeout?

It sounds sooo trivial, I use volley to request two JSON data packets, but the second one fails - if I leave the first out, it all works. It even fails if I requery test1() multiple times.

    private void test1()
    {
    JsonArrayRequest req =
            new JsonArrayRequest(Request.Method.GET,
                                 "https://www.impfterminservice.de/assets/static/its/vaccination-list.json",
                                 null,
                                 new Response.Listener<JSONArray>()
                                     {
                                     @Override
                                     public void onResponse(JSONArray response)
                                         {
                                         test2();
                                         }
                                     },
                                 new Response.ErrorListener()
                                     {
                                     @Override
                                     public void onErrorResponse(VolleyError error)
                                         {
                                         test2();
                                         }
                                     }
            );
    BaseMainApp.getVolleyRequestQueue(m_Context).add(req);
    }

private void test2()
    {
    JsonObjectRequest req =
            new JsonObjectRequest(Request.Method.GET,
                                 "https://002-iz.impfterminservice.de/rest/suche/termincheck?plz=78224&leistungsmerkmale=L922",
                                 null,
                                 new Response.Listener<JSONObject>()
                                     {
                                     @Override
                                     public void onResponse(JSONObject response)
                                         {
                                         // does not arrive here
                                         }
                                     },
                                 new Response.ErrorListener()
                                     {
                                     @Override
                                     public void onErrorResponse(VolleyError error)
                                         {
                                         // OUCH!!!
                                         }
                                     }
            );
    BaseMainApp.getVolleyRequestQueue(m_Context).add(req);
    }

I thought it might be the cookie cache, but I tried without cache

        Cache   cache   = new NoCache();
        Network network = new BasicNetwork(new HurlStack());

        m_VolleyRequestQueue = new RequestQueue(cache, network);
        m_VolleyRequestQueue.start();

or I tried to delete the cache, ... to no avail. I also tried to delay the second query, create a new RequestQueue, ... I really need to restart the application!

What is going on there? What is causing the server to deny my request (and deny it with a timeout)?

By the way - the second query can be called multiple times if the first is not done, so I guess the first sets some state somehow... whatever it is?



from Android Volley: Why does the second request of these two requests fail with a timeout?

No comments:

Post a Comment