HTTP calls in same wireless network glassfish - android

I have an endpoint which is available at following url: http://localhost:18080/app/register (via POST request). I want to make calls to this endpoint from my Android device, which is in the same Wireless network (the IP for the laptop running the server is 172.16.xx.xx). When I am making my request from the laptop (server) to this endpoint: http://172.16.xx.xx:18080/app/register, everything works fine.
When I am making the POST request from my Android device to the same endpoint, I get back a 400 Bad Request with message "The request sent by the client was syntactically incorrect". I checked the URL, I checked the JSON, I made the request with exactly the same body via curl from my laptop and everything looks fine.
Has someone experience this problem before? I don't know where I should start from with my investigation. I am deploying my application on Glassfish 4.1.2

Related

Ionic $http request get not working with error data null status -1

I use Ionic and Cordova framework for developing a mobile app, I've got the issue that can not use http get to request some url. For $http.get to some url that works fine, but some others not work and it response error like as
I/Web Console( 9179): {"data":null,"status":-1,"config":{"method":"GET","transformRequest":[null],"transformResponse":[n ull],"url":"http://someexmaple.com/","headers":{"Accept":"application/json, text/plain, */*"},"withCredentials":true}," statusText":""}
This issue only happens when I test on real mobile device and using adb debugging tool. But I tested on Browser and Genymotion virtual devices, both of them worked well for all url request.
So I've know idea with this response error. I think may be my device got problem.
Finally I've resolved my problem. I use inspect tool in Chrome, and move to network tab for watching the network packet, I see when I access to the url of site, it redirect me to another server port (instead of 80, it redirect to 443), I've noticed this because the 'Remote Address field' is the same address of url server, but port was changed. So I changed my $http.get request url from port 80 into port 443. And then it works, so I guess that when $http.get to the url but it didn't redirect to another port to get data, so it just response the null.

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.

Authorization problem in Android with glassfish

I'm writing an HTTP client in Android that connects to glassfish on my localhost and sends some json information to the server.
I use:
UsernamePasswordCredentials cred =
new UsernamePasswordCredentials(SettingsHelper.mUser, SettingsHelper.mPwd);
client.getCredentialsProvider().setCredentials(AuthScope.ANY, cred);
for authontication, and making a put request.
The problem is sometimes, the client sends an unauthorized request before retrying and sending an authorized one, and on the second time, it pushes the json entity, before getting a proper response from the server (100 - continue). then, the server doesn't respond at all, and everything hangs.
i will note that sometimes it works.
Has anyone else experienced this problem? How might I resolve it?
finally managed to make it work with basic pre-emptive authontication.
example here

Categories

Resources