How do I get my Android Emulator to talk to a local Rails-based API?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



How do I get my Android Emulator to talk to a local Rails-based API?



So I have an app built using Expo for both Android and iOS.



Now, this App needs to make fetch requests to a local API/gateway server that is based on Ruby on Rails, running using Foreman/Passenger.



The app is currently running inside an AVD (android emulator). I'm using macOS.



The AVD can access the local API/gateway using its built in Chrome browser. I can make simple GET requests to the root endpoint of the server, and use the Admin panel we've built in. This is all done insecurely though, because our Chrome isn't trusting the Server's certificate.



(We generated some SSL certificates that are CA signed, and Passenger is deploying these)



The Main Issue



Whenever we have our React Native app make requests to the local server (say, https://10.0.2.2:44300 in our case, since 10.0.2.2 is used to expose the Mac's localhost to Android), the requests simply don't go through. They time out.


https://10.0.2.2:44300



Example error output



I've been trying to figure out why this is happening, and I'm sure if it has anything to do with the certificate not being trusted by my device.



On iOS everything works fine, but we had to manually install the certificate that our server uses. Since Simulator recognizes localhost as the computer's localhost, this isn't an issue but the same certificate doesn't work for Android.



What are some possible ways to troubleshoot this?



Thanks!





If it was a certificate problem you'd get a different error. The TCP connection must complete successfully before the SSL handshake even begins. Perhaps you can edit your question include the full stacktrace of the timeout exception to help diagnose the problem.
– James K Polk
Aug 9 at 19:58





@JamesKPolk unfortunately the Stack trace isn't very descriptive. This is really all I see: paste.pics/7bb9e75b0e91d30a5bc8bfcd127866bd
– OmriSama
Aug 9 at 20:06





And if you enter https://10.0.2.2:44300/api/v1/mobile_user/settings into Android's Chrome browser it connects successfully?
– James K Polk
Aug 9 at 20:50



https://10.0.2.2:44300/api/v1/mobile_user/settings









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

make 2 or more post in bootsrap

Store custom data using WC_Cart add_to_cart() method in Woocommerce 3

Firebase Auth - with Email and Password - Check user already registered