Wednesday, 19 April 2017

Heroku 503 server error when using GoogleMaps Marker's OnClickListener

I have an android activity that displays a map with markers. I set on marker click functionality in the onMapReady() method. There is one server request made to my Heroku server from this on click listener:

mMap.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() {
            @Override
            public void onMapLoaded() {
                MapStyleOptions options = new MapStyleOptions("[]");
                mMap.setMapStyle(options);
                mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
                    @Override
                    public boolean onMarkerClick(Marker marker) {
                        LatLng loc = marker.getPosition();
                        String userId = listingPointers.get(loc);
                        if (userId != null) {
                            SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
                            String token = preferences.getString("token", "");
                            Response.Listener<JSONObject> responseListener = new Response.Listener<JSONObject>() {
                                @Override
                                public void onResponse(JSONObject response) {
                                    try {
                                        String firstName = response.getString("firstName");
                                        String lastName = response.getString("lastName");
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                    }
                                }
                            };
                            JSONObject request = new JSONObject();
                            Response.ErrorListener errorListener = new Response.ErrorListener() {
                                @Override
                                public void onErrorResponse(VolleyError error) {
                                    test = false;
                                }
                            };
                            String address = "https://abcd.herokuapp.com/users/" + userId;
                            GetSingleRequest infoRequest = new GetSingleRequest(address, token, responseListener, request, errorListener);
                            RequestQueue queue = Volley.newRequestQueue(getApplicationContext());
                            queue.add(infoRequest);
                        }
                        return false;
                    }
                });
            }
        });

I get a 503 status code from the Heroku Server, with an error code H10. I have no idea what causes this problem, and it causes the whole server to become unresponsive until I reset it.



via Shobhit Srivastava

No comments:

Post a Comment