I've set up an ec2 instance in aws with a parse server on it. I'm using it for an android app and it works just fine from the emulator on my host machine, except that it doesn't from any other machine/device - be it another emulator from another pc, doesn't matter if its on the same network or not, or an android phone.
I tried setting up another parse server in back4app and it works just as expected there, however that is not that much of a good solution since the free plan reaches its limit in the middle of the workflow of my app and that's not sufficient even for the presentation that I have to make.
As for the aws - I opened all traffic for all ports both on the inbound and outbound tabs from the security group - still nothing.
I tried accessing the dashboard via browser from another device and that works just fine but whenever I try to login from the app, it just times out - no response. Logs don't show anything, except for the fact that I have received the timeout toast. I tried connecting both to the dns and the public ipv4
Parse.enableLocalDatastore(this);
Parse.initialize(new Parse.Configuration.Builder(getApplicationContext())
.applicationId("{{appId}}")
.clientKey("{{masterKey}}")
.server("http://{{addr}}:80/parse/")
.build()
);
I'm pretty certain that its something to do with aws's security policy that I have missed to configure, since I'm not changing anything major when I try to connect to the back4app and the aws. Fact is - they both work from the emu, but aws doesn't from the phone.
Related
My react-native android app uses the IP address of a smart device on the local network to communicate with it. This works perfectly in testing but now that I've launched the app for internal testing this call fails.
Ex call is: http://192.168.88.39:8080/version
This call works perfectly in development, but not on the deployed app. I was previously using a hostname to resolve the IP address of the device on the local network but realized this didn't work with Android, so I switched to using the IoT device's IP address to communicate with it.
But to my surprise that isn't working. I've also tried to setup a Charles proxy to intercept the requests but have been unable to do so successfully so I'm not sure what the exact response is from the http request.
But I know it doesn't resolve.
So firstly is this even possible to do? Want to make sure this is not prohibited?
You cannot access http urls in a production build. Check this question for possible solutions Android 8: Cleartext HTTP traffic not permitted
I'm using getUserMedia() in my web app which works fine when I test my app on localhost. But if I treat my laptop as server and launch app in Google Chrome browser of my android phone, it gives me the error:
getUserMedia() no longer works on insecure origins. To use this
feature, you should consider switching your application to a secure
origin, such as HTTPS. See https://goo.gl/rStTGz for more details.
When I checked [https://goo.gl/rStTGz][1] I got to know that getUserMedia() is deprecated on insecure origins. It is written that for development mode,
You can run chrome with the
--unsafely-treat-insecure-origin-as-secure="example.com" flag (replacing "example.com" with the origin you actually want to test)
How and where can I set this flag? Is there any other alternative?
This can be done from chrome://flags/ or about://flags.
Go to about://flags, search for unsafely-treat-insecure-origin-as-secure flag, and enable it. You will have to provide the origin which you want to be treated as secure.
Multiple origins can be entered as comma-separated values.
Relaunch your browser after making this change.
Note that the protocol part is also important, and specifying the IP address, or the domain name isn't enough. eg. http:// in http://192.168.43.45. If you are not using port 80, then you may have to specify that too.
The following is a screenshot from my mobile phone.
Mobile: Samsung Galaxy S10e
Android version: 10 (Android 10)
Google Chrome version: 79.0.3945.136
For local testing of a website I am building, geolocation was needed.
Geolocation is allowed in secure locations. I do have a production server with HTTPS certificate, but the development and the debugging process would become too slow if I have to upload content to it every time.
More info
https://www.chromium.org/Home/chromium-security/prefer-secure-origins-for-powerful-new-features
Move localhost to the device
One method is to run an HTTP server on your Android device. The consensus in answers to this question is that NanoHTTPD is worth trying. If you want a ready-made application, a web search for http server for android turned up Simple HTTP Server on Google Play Store. After copying the client side of your web application to the device and starting the server, you should be able to open http://localhost:12345 in Chrome for Android.
Or make your test server secure
You can test secure-context-only features without using --unsafely-treat-insecure-origin-as-secure by turning your existing test server into a potentially trustworthy origin. Follow these steps:
If you do not already own a domain at a registrar that bundles DNS hosting compatible with the dehydrated ACME client, register one. This incurs a fee, which recurs as long as you keep the domain active.
Point a subdomain at your test web server's internal IP address. It need not be reachable from the Internet.
Configure your test web server to respond to HTTPS on port 443 of this subdomain, using NameVirtualHost or the like.
Use the dehydrated ACME client with the appropriate dns-01 hook for your DNS host to obtain a certificate from Let's Encrypt for your test web server.
Install this certificate into your test web server.
I faced with this problem too, but in Chromium, Ubuntu. I solved the problem with running this command in console:
chromium-browser --unsafely-treat-insecure-origin-as-secure="http://localhost.dev:3000" --user-data-dir=~/.config/chromium/Profile 1
where localhost.dev:3000 is your website.
For other systems information there:
where is data directory
how to launch chrome and set keys
Short information about --unsafely-treat-insecure-origin-as-secure flag:
Treat given (insecure) origins as secure origins. Multiple origins can
be supplied. Has no effect unless --user-data-dir is also supplied.
Example:
--unsafely-treat-insecure-origin-as-secure=http://a.test,http://b.test --user-data-dir=/test/only/profile/dir
I didn't check, but for android you maybe can also set flags on chrome://flags page.
If i use local database, say MySQL, it works perfect on simulator and emulator but for real device, localhost won't do, So i tried online database hosting.
When using online hosting from www.freemysqlhosting.net, i had setup the database in my database development perspective in Eclipse using the provided id and password, so it worked well on my simulator, emulator and real device that was connected to the same network as that system on which that database was setup, but for any anonymous device,it failed!
Then i tried with sqllite, again it worked with simulator and emulator but for real device,it showed UNRESPONSIVE_HOST error.
My question is: if i want to develop an app using IBM Worklight that uses some database and want to distribute it, how can i do it?
It would have been far far more helpful if you'd just provide the error log from LogCat...
When using Android, it is a good practice to not use localhost, instead to use the actual IP address. See this question: IBM Worklight - Unable to connect to database when using IP address instead of localhost
MySQL is a server like any other server; if you want to use it outside of your private local network, then you simply need to open it to incoming connections from the public Internet. This is not something a developer needs to fuss around with, that's what IT departments are for. So google and see how to open your network.
This sounds as though you are trying to access a database directly from your device. Is that the case?
I would strongly recommend using Worklight Adapters here. So the pattern goes:
App on Device ---> Adapter ---> Database
In that pattern the responsibility for getting from Device to the Adapter lies with Worklight and hence should be completely unaffected by whether it's a real device or an emulated one, and should also be independent of what particular database you are using or where it it.
The hop from Adapter to Database is something you can set up and test without even having an deployed anywhere. Just use the test environment in Eclipse to call adapter methods.
Why not go from device directly to database? In general that's a really bad security pattern, you're effectively putting data you care about in a very hackable place. Also it will not scale well to large numbers of users: connecting directly from the device means that effectively every user has their own connection, going via the adapter users share a controllable number of connections.
Your problem is not with the SQL server it is with the connection between the device and the Worklight server. You need to be able to connect from the device to the Worklight server. Open a browser on the device and point it to the Worklight console and see that you can access it.
Hello I am making an Google Appengine hosted HTML5 webapp. It is going swell so far except that every time i want to test the webpage I have to upload it to the server so that my phone can go and get the url.
Is there any way to test a local server on my win machine on my webview?? I am really getting sick of having to upload it to appengine, seeing somethin minor wrong in the webview rendering and having to reupload it again.
Thanks
Ruben
If you're on the emulator or on the same network, your win machine is the server.
You just need to get its IP by going to command prompt and writing the command ipconfig
And use this IP on your android application
For a more detailed way to get the ip :
http://www.youtube.com/watch?v=49tYGwBhP3Y
By default, the local dev server only allows connections from the same machine. If you want to use the Android emulator, that's fine (but it sounds like you don't want to use the emulator from the comments).
You should use the --host parameter (in recent versions of the SDK) to bind your server to an address that will be visible on your network, e.g.:
dev_appserver.py --host=0.0.0.0 .
Once you've done this, you can point your web view to the address of your machine on the LAN.
I've migrated a web application that sends push notifications to Android apps using Google Cloud Messaging from my local workstation to a server.
Connecting to https://android.googleapis.com/gcm/send worked perfectly from my workstation. My list of allowed IPs in my Google API project includes my server's IP (and I've triple checked it), but when I connect using the exact same API key from the server, I am always getting a 401 (unauthorized) response back from Google.
I am connecting from a Linode VPS, and when I wget the same URL, I can see that it is going over IPV6. I've copied my server's IPV6 address from http://whatismyv6.com/ and also included that in the list of allowed IPs, but still I'm still only getting 401 responses.
My guess is it's related to IPV6, so I'll go ahead and try to force connecting over IPV4- but I'm curious about whether anyone else has experienced this.
Interesting. It suddenly just started working. Out of curiosity, I removed my IPV6 address, tried again and it failed. Then after adding it back, it failed a few times before started working again.
It seems that it may just take a little while for Google to accept the IPV6 address?
I guess I'll leave this question / answer though, in case anyone else experiences it. Make sure your server's IPV6 address is in the allowed list, then just go refill your coffee and try again later.