I have this ionic app that consumes from a server api (Spring). When i use capacitor to use the android version it works fine on the emulator from android studio, but when using a real device the http requests doesn't work. It retrives the message: "Msg: Status: 0, Message: Http failure response for http:///login: 0 Unknown Error". Things i tried: Disabled the firewall and use the same wi-fi from server.
message from server
Related
After enabled https on back end nodejs server, the http request URL was changed from http to https in React Native 0.66 app. Now in Android emulator (API 27), the app does not send out any http request to back end server at all. android:usesCleartextTraffic="true" was added to AndroidManifest.xml but it didn't help (removing it has no impact either). It must be the issue about late android API which requires https in production. But I don't quite understand why https didn't work in Android emulator.
The development platform is macOS Big Sur for both IOS and Android which open their own emulators respectively. The IOS version of the app works fine after https was enabled. But android version of the app does not.
when I try to run my application on Android Studio, the connection with my API REST Symfony don't working. It's my file capacitor.config.json, I have adding "server": { "url": "http://localhost:8000/login" }screenshot file I have a response with status code 200 OK (when it's work and don't), while that should send me back my user. my error
I use Capacitor on Ionic and I'm in localhost.
I'm trying to create an Android app with Ionic to send messages to a Node.js server. I'm using socket.io#2.3.0 for the server and socket.io-client#2.3.0 for the Ionic app. The Ionic app is supposed to open a socket.io connection with the server, then send the message "Hello, World!". The Ionic app build for the web works properly, I tried running it from other devices (my laptop and my phone) and in both cases the socket.io connection worked and the server printed out the message received from the Ionic app.
// Server output
Server running on port 5000.
New connection from 7rI7qvo9gNjVD5ElAAAA
Hello, World!
But when I build the Ionic app for Android using the commands:
ionic cap add android
ionic cap open android
And then debug from Android Studio, the app launches, but I don't see any message from the server, and I don't even see an error message in the Android Studio debug tab.
// Server output
Server running on port 5000.
At first I thought this was a network problem so I made sure the AndroidManifest.xml file included the permissions INTERNET and ACCESS_NETWORK_STATE, I tried building an APK and running it on my phone, but it still doesn't work so I don't know what I should do.
I'm using the version 5.4.16 of Ionic.
Thanks for reading this, have a nice day :)
I fixed this issue by hosting the Node.js server on Heroku, now everything works fine, I'm not sure why though. Since the protocol changes from http to https when I host the server on Heroku, I'm guessing Android doesn't like the http protocol.
I am getting the following error while registering the device for push notification in android,
Failed to register
device:"com.ibm.mobilefirstplatform.clientsdk.android.push.api.MFPPushException:
Response: Status=400, Text:
{\"errorCode\":\"invalid_client\",\"errorMsg\":\"Incorrect JWT
format\"}, Error Message: Incorrect JWT format"
MFP Server: 8.0.0.00-20170220-1900
Cordova : 6.1.1
cordova-plugin-mfp : 8.0.201703309
cordova-plugin-mfp-push: 8.0.2017012410
Found the similar question but no clear figure :
IBM MobileFirst v8 trying to obtain Token on android cordova app after successful login challenge handler
Cordova Android application getting "invalid_client" from Mobile First 8.0 server
Any solution or suggestion will be appreciable.
Looks like you are missing the step in the android platform. In Android Studio, add the following activity to the application tag:
<activity android:name="com.ibm.mobilefirstplatform.clientsdk.android.push.api.MFPPushNotificationHandler" android:theme="#android:style/Theme.NoDisplay"/>
The most common cause of the issue is failure in time synchronization between client and server. Verify if the server time if offset from the client. Specifically if the server has a time in past.
I had the same issue, Rebooting the client device / emulator helped me.
( The the "check server time" was not practical for me, my Server runs as Bluemix service in US )
BTW: I can reproduce this "Incorrect JWT format" in the android emulator: If the android emulator is running overnight and I try the next day, I always get this error (until restarting the emulator)
I am working on a project that allows Android Built Ionic version 2 app to create user and authenticate to a Django dev site through Django Rest API.
The authentication works when using ionic serve this was achieved through the use of Cross Origin Resource Sharing (installed as google chrome plugin).
As I've tried to run the application on an actual android device, the authentication fails (HTTP 404: URL not found) when using the app but the localhost can be accessed through browser of the same device (through 192.168.22.4:80).
Details:
My current private IP address is 192.168.22.4 and the dev site is currently being served at the localhost port 80 through Wamp Apache Server.
Here is the code fragment of my http request on Ionic App (signup):
let headers = new Headers();
headers.append('Content-Type','application/json');
this.http.post("http://192.168.22.4:80/api-user-create", JSON.stringify(this.postData), {headers: headers}).subscribe(res => {
console.log(res.json());
this.showAlert();
}, (err) => {
console.log(err);
});
Applied Solutions:
These are the steps that I have tried but still failed to connect to the localhost:
Ensure that the app is allowed to access to WiFi connection, verify whether my IP address is correct, turned off my firewall and even my antivirus. I have also enabled network discovery on my dev server.
Use proxy server (ngrok) and edit Ionic request
Enable CORS on Apache Server and edit Ionic request
Edit Ionic request code. I have tried to changed 192.168.22.4:80 to:
192.168.22.4
127.0.0.1:80
127.0.0.1
localhost:80
localhost
10.0.2.2
10.0.2.2:80
Has anyone encountered this problem and solved it?
Problem solved!
I have solved it by:
Make wamp listen to the < ip address >:< port number >. It was initially set to 0.0.0.0:80 by default. To configure, I updated the httpd.conf on my wamp server then added the line:
Listen 192.168.22.4:80
install cordova-plugin-whitelist on my ionic project. To do this, I have to run:
cordova plugin add cordova-plugin-whitelist --save
edit my Ionic code and removed the port number to the request:
let headers = new Headers();
headers.append('Content-Type','application/json');
this.http.post("http://192.168.22.4/api-user-create", JSON.stringify(this.postData), {headers: headers}).subscribe(res => {
console.log(res.json());
this.showAlert();
}, (err) => {
console.log(err);
});
rebuild and run the application
Read Ionic App - No Internet Access for more information.