4

I'm making a string request with Volley. Here's the error:

basicNetwork.performRequest: Unexpected response code 503 for http://...

The problem is not the url. I've checked that already. The url is an address to some XML that looks like this for example:

    <config>
        <Request name="ValidateEmailRequest">
            <requestqueue>emailrequest</requestqueue>
            <responsequeue>emailresponse</responsequeue>
        </Request>
        <Request name="CleanEmail">
            <requestqueue>Cleanrequest</requestqueue>
            <responsequeue>Cleanresponse</responsequeue>
        </Request>
    </config>

Here is my request code:

StringRequest myReq = new StringRequest(

    Request.Method.GET, 
    url,

    new Response.Listener<String>()
    {
        /** On response **/
        @Override
        public void onResponse(String response) {
            processData(response);
        }
    },

    new Response.ErrorListener()
    {
        @Override
        public void onErrorResponse(VolleyError error) {
            // handle error response
        }
});

Is my request queue the problem? I'm making multiple request from different classes to the same static request queue, but that hasn't been a problem until now.

e.g.

MyOtherClass.getRequestQueue();
//Request code for this class...
MyOtherClass.RequestQueue.add(myRequest);

edit

My urls are working. They expire pretty fast because they are signed, but here is one anyways.

http://webservices.amazon.com/onca/xml?AWSAccessKeyId=AKIAJ6L6R4KOPIYIUXUA&Artist=Bill%20Evans%20Trio&AssociateTag=mytag-20&Operation=ItemSearch&SearchIndex=Music&Timestamp=2015-12-18T06%3A15%3A23Z&Title=Sunday%20At%20the%20Village%20Vanguard&Signature=QG97Kngo6khD7jAD0TUIXmy07SW0fmKTsrKnUsaBvYw%3D

the_prole
  • 8,275
  • 16
  • 78
  • 163
  • Response code 503 means an error at the server side "Service Unavailable". Check the server logs what happended. – Henry Dec 18 '15 at 06:11
  • I'm using the Amazon Web Service, so I can't. But urls themselves are fine. But the urls themselves are fine. When I copy and paste the urls into the browser, they work. Just not with Volley. – the_prole Dec 18 '15 at 06:13
  • Pls post that AWS url so that we can check :) – BNK Dec 18 '15 at 06:14
  • @BNK The url is signed, so it expires pretty quickly. I'll post one anyways. – the_prole Dec 18 '15 at 06:14
  • @BNK http://webservices.amazon.com/onca/xml?AWSAccessKeyId=AKIAJ6L6R4KOPIYIUXUA&Artist=Bill%20Evans%20Trio&AssociateTag=mytag-20&Operation=ItemSearch&SearchIndex=Music&Timestamp=2015-12-18T06%3A15%3A23Z&Title=Sunday%20At%20the%20Village%20Vanguard&Signature=QG97Kngo6khD7jAD0TUIXmy07SW0fmKTsrKnUsaBvYw%3D – the_prole Dec 18 '15 at 06:15
  • Logcat info, working :) `12-18 13:17:36.757 2268-2268/com.example.samplevolley I/onResponse: ` – BNK Dec 18 '15 at 06:18
  • @BNK You got it working already? – the_prole Dec 18 '15 at 06:19
  • Yes, so I posted my logcat – BNK Dec 18 '15 at 06:19
  • 503, I think the problem is from the AWS server, http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html – BNK Dec 18 '15 at 06:21
  • @BNK I see, but if volley works for you, maybe the problem is in my code? – the_prole Dec 18 '15 at 06:23
  • My code is very simple, as the following http://pastebin.com/raKTKY4y – BNK Dec 18 '15 at 06:28
  • The server does not support the HTTP protocol version used in the request. – Pankaj Nimgade Dec 18 '15 at 06:34
  • @BNK Thanks, but your code has the same result. Maybe [this](http://stackoverflow.com/questions/17094718/change-volley-timeout-duration) is the solution. – the_prole Dec 18 '15 at 06:35
  • @PankajNimgade What do you mean? The URL works if I copy it manually. Does volley not use the right protocol? – the_prole Dec 18 '15 at 06:35
  • 1
    @BNK Yep! That was it. Thanks ! =) – the_prole Dec 18 '15 at 06:41
  • @BNK Okay, now it working without the code. I don't know what to say. Thanks anyways. – the_prole Dec 18 '15 at 06:44
  • You're welcome, 503 is server problem, not client, if timeout, volley got no resp code :) – BNK Dec 18 '15 at 06:45
  • @BNK What does resp mean? – the_prole Dec 18 '15 at 06:46
  • Ah, HTTP response code :) – BNK Dec 18 '15 at 06:50
  • @the_prole, are not dependent to the library, it is something you provide to the library so it can make appropriate call, things you need to gather before you call the API is as following. 1:- find out what Method name do you require eg. "PUT","GET","POST" etc 2:- Check what headers are required for the API you are calling. 3:- Check what parameter are requested by the API – Pankaj Nimgade Dec 18 '15 at 07:07
  • @PankajNimgade I already have all that. The Url is enough. The Url IS the request. – the_prole Dec 18 '15 at 07:09
  • @the_prole, in that case a simple GET method should be enough to get the information, but apparently there should be more to it, i guess some parameter values are changing and the API has to get it to produce the information – Pankaj Nimgade Dec 18 '15 at 07:52
  • @PankajNimgade Thanks for the advice. The problem was I was making to many requests to the same product image and the server was timing out. – the_prole Dec 18 '15 at 08:01
  • @the_prole it's alright, things like this happen all the time :) – Pankaj Nimgade Dec 18 '15 at 08:03

2 Answers2

0

HTTP Error 503 - Service unavailable
This means that networkResponse is null because in a TimeoutError no data is received from the server.

You can also check the error type from the following code.
Thanks to Submersed.

@Override
public void onErrorResponse(VolleyError error) {

    if (error instanceof TimeoutError || error instanceof NoConnectionError) {
        Toast.makeText(context,
                context.getString(R.string.error_network_timeout),
                Toast.LENGTH_LONG).show();
    } else if (error instanceof AuthFailureError) {
        //TODO
    } else if (error instanceof ServerError) {
       //TODO
    } else if (error instanceof NetworkError) {
      //TODO
    } else if (error instanceof ParseError) {
       //TODO
    }
Salmaan
  • 3,543
  • 8
  • 33
  • 59
  • But the urls themselves are fine. When I copy and paste the urls into the browser, they work. Just not with Volley. – the_prole Dec 18 '15 at 06:13
  • @the_prole thats awkward! Try increasing timeout! – Salmaan Dec 18 '15 at 06:16
  • Yes, that was the problem! I found the solution [here](http://webservices.amazon.com/onca/xml?AWSAccessKeyId=AKIAJ6L6R4KOPIYIUXUA&Artist=Bill%20Evans%20Trio&AssociateTag=mytag-20&Operation=ItemSearch&SearchIndex=Music&Timestamp=2015-12-18T06%3A32%3A02Z&Title=Sunday%20At%20the%20Village%20Vanguard&Signature=cV79hLQv5jm%2BMT2MRBmW3P1P3QECMxr0vJdLsHkfiGk%3D) – the_prole Dec 18 '15 at 06:42
  • @the_prole Hahaha Request has expired. Timestamp date is 2015-12-18T06:32:02Z. :p – Salmaan Dec 18 '15 at 06:52
  • I take that back... that did not solve my problem =( I think my problem is I need to make another request queue – the_prole Dec 18 '15 at 06:54
0

I think my problem was that I was making too many requests at the same time to the same product image on Amazon. As soon as I limited the number of request I made to the same product image, I stopped receiving the 503 error.

the_prole
  • 8,275
  • 16
  • 78
  • 163