[英]Access server running locally from Appcelerator mobile app installed to android device
I have a Spring Restful API Server running locally on my machine. 我的机器上本地运行着一个Spring Restful API Server。
I start/stop it as a Tomcat App server via Eclipse's Server's tab. 我通过Eclipse的“服务器”选项卡将其作为Tomcat App服务器启动/停止。
I also have built an Appcelerator app that makes calls to this server. 我还构建了一个Appcelerator应用程序,可以对此服务器进行调用。
When I run my app via the Android Emulator option in Titatium Studio it connects and retreives data fine from my local server. 当我通过Titatium Studio中的Android Emulator选项运行应用程序时,它可以连接并检索本地服务器上的数据。 The request is:
请求是:
var TRANSACTIONS_URL = 'http://myipaddress:8080/PurchaseAPIServer/api/purchase';
I encounter a problem when I connect my android device to machine via a usb cable (in developer mode) and install/run the app on Android Device with Titanium Studio . 当我通过usb电缆(在开发人员模式下)将android设备连接至计算机并在Titanium Studio上的Android设备上安装/运行该应用程序时遇到问题。
My locally running server is never been hit. 我的本地运行服务器从未受到攻击。
I have tried options mentioned in this article but had no luck: Accessing webserver running within Eclipse from outside the workstation 我尝试了本文中提到的选项,但是没有运气: 从工作站外部访问在Eclipse中运行的Web服务器
Is there a way to get around this? 有办法解决这个问题吗?
Thanks 谢谢
Connecting my Samsung Galaxy S2 to local wifi connection (PC using same wifi) fixed the problem. 将我的Samsung Galaxy S2连接到本地wifi连接(使用相同wifi的PC)解决了该问题。 No need for usb cable either of course once it's installed on device.
将USB电缆安装在设备上后,当然也不需要。
Following links may be useful: 以下链接可能有用:
Accessing localhost of PC from USB connected Android mobile device 从USB连接的Android移动设备访问PC的本地主机
How can i access my localhost from my android device? 如何从Android设备访问本地主机?
are you trying to test this by sending the request through the USB cable? 您是否正在尝试通过USB电缆发送请求以对此进行测试? USB's do not use ip address to communicate so i'm not sure exactly how that is suppose to work.
USB不使用IP地址进行通讯,因此我不确定该如何工作。
This should work fine if you connect both to a wifi source, I have done this in the past myself. 如果您同时将两者都连接到wifi信号源,则此方法应该可以正常工作,我过去自己也这样做过。 it also makes more sense as if this is intended to be published as an app users will not be connecting to your server via a USB.
这样做似乎更有意义,因为它打算发布,因为用户将不会通过USB连接到您的服务器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.