WAMP Server, started getting 403 forbidden response from Android activity - android

I have a web service which is hosted on my WAMP Server. URL: http://localhost/appname/service.php
I have an Android application which calls methods of the web service.
In LogCat I can see the response is a generic HTML page saying 403 Forbidden, you do not have access to the page etc, however when I go to the URL which the Android code called I can access the service just fine.
In the Apache error log I have
AH01630: client denied by server configuration: C:/wamp/www/appname/service.php
How come I can access the URL directly through my browser but not through my device? Both are on the same wifi network.
This was working previous (for the past month).

First tip: Your networking job should be made inside AsyncTask instead of an Activity. http://developer.android.com/reference/android/os/AsyncTask.html
Second tip: How are you building your HTTP request?

Related

Android: How inspect http(s) request headers?

I'm developing an Android application, it is like a browser, has a web-view and sends http(s) requests. For debugging purpose, I want to be able to see the requests sent and received by the application (in particular the headers), but I'm unable to do so.
What i tried
I mainly debug the app with Chrome on PC, and use the Network Inspector in Chrome. The problem is that my app uses the ShouldInterceptRequest to intercept the requests an then manually sends a request with cronet. Chrome, in this case, shows some "provisional headers" that are from the original request, an not the headers of the actual request i sent manually.
I tried to use Fiddler and HTTP Toolkit, but the server I'm communicating with, doesn't like the certificate they use, so they can monitor correctly, but, if active, i cannot reach the page i need to monitor.
I also tried the Android Studio network inspector, but seems it work only for HttpURLConnection and Okhttp(1)
Thanks for your time.
If you're using a WebView, set a custom WebViewClient and override shouldInterceptRequest. That will pass in a WebResourceRequest object that will include all headers.

403 AuthFailureError in Volley

I am having a very strange situation. I have a running script that makes JsonObjectRequest using Volley Singletone. The script has been working perfectly in domain example1.com. Recently I bought example2.com and hosted in the same hosting account. And when I copy all the php files as it is in the second domain, I am getting error "BasicNetwork.performRequest: Unexpected response code 403".
So, I have exactly same php files called using JsonObjectRequest and Volley Singletone working in example1.com, but not in example2.com. I have check the permission of the files in both domain, they are exactly same (644) and there is no htaccess in either of the domain.
I am stuck and don't understand what else I should check?
Any help will be highly appreciated.
Problem is with your server side php script - You can first try to test POST requests using some tool before implementing in your Android application:
If I performed a simple POST request (just using browser not Android) to your provided link I get following error:
403: Forbidden
403 Forbidden Forbidden You
don't have permission to access /mylibman_4_5.php on this server.
Additionally, a 404 Not Found error was encountered while trying to
use an ErrorDocument to handle the request. Apache
Server at mylibrarymanager.com Port 80

EOFException after server responds

I have a quite simple problem but I've still couldn't find a solution yet.
What I want to accomplish:
I'm trying to establish a reliable connection between a smartphone running Android and the ESP8266 wifi module. I would like to send short HTTP string messages, where the phone plays the role of a client and the ESP8266 of a server. For managing HTTP requests I'm using the Volley library.
What already works:
I am able to do a successful HTTP GET request to the ESP8266 from a browser running on the Android phone. I also managed to use Volley to make a GET request to a server running on the web.
What doesn't work:
On the other hand, I cannot successfully send a GET request to ESP8266 using Volley. To be more precise, I get an EOFException when the server (ESP8266) tries to close the connection after it has responded. When using a browser the body of the response gets displayed after the connection is closed but in case of Volley the connection closing fails and shuts down the server.
I have no idea how to solve this problem/bug. What frustrates me is that the same commands for sending a HTTP response on the ESP work well when using a web browser but fail when using Volley. So I guess the problem is something about Volley.
Any ideas why Volley throws such exception? Any help would be deeply appreciated.

Bad request when connecting to ASP.NET page on IIS from android application

I have a ASP.NET website deployed to IIS with a couple of ashx that returns JSONs to be consumed by an Android application.
I have implemented an authentication logic using Basic Authentication.
The problem: When accessed from Android, the server response is a 400 Bad request. The httperr log file says "400 - Hostname -".
It works when I try it out on localhost from Android emulator
It works when accessing the ashx file on the server from a browser
It works when replicating the call in Fiddler
(If I use Fiddler with the Android Emulator, the Response will be -1 (and looking in Fiddler at the raw data sent, it seems to loose the host from the url) - but this is another issue so don't dwell on that, i just thought I would mention it...)
Turns out my problem (and solution) was the same as in this thread:
HTTP POST request with authorization on android

Check HTTP request against reliable server

In my android app i keep getting timeouts in the messages between the app and my server.
In an attempt to see if the problem is in the app or my server,
i want to try and Send an HTTP request from my app to
some other server i am sure is up and reliable and then see if i get timeouts.
Is there any server address i can check against?
Thanks in advance!
BTW : i am using a glass Fish servlet for my server
We've successfully sent a simple HTTP GET to google.com -- with a couple of fall-backs (I've also seen internic.org used) in the past, in similar cases.

Categories

Resources