通过wifi从android访问本地主机 [英] Accessing localhost from android over wifi

查看:28
本文介绍了通过wifi从android访问本地主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个 Https 网络服务,所以它是用 SSL 加密的.

I have written a Https webservice, so it is encrypted with SSL.

为了测试,我想通过 wifi 访问该网络服务.

For testing i would like to acces that webservice over wifi.

edit 示例:我的网络服务在编号为 111 的 VM 上运行,我想通过 wifi 访问它,因此地址为 https://VM111/Webservice/service.svc.我可以从 wifi 网络中的任何笔记本电脑访问它,但不能从 Android 手机访问,这是我的问题.

edit Example: My webservice is running on a VM number 111, i want to acces it over wifi so the adress would be https://VM111/Webservice/service.svc. I can acces it from any laptop in the wifi network but not from the Android Phone, that is my problem.

有没有办法从 Android 手机访问 VM 的本地主机,以前有人处理过吗?

Is there a way to acces the localhost of the VM, from the Android phone, and has anyone dealt with this before?

我猜这与域有关,因为其他所有设备都在 Active Directory 中.

My gues is that is has something to do with domains because every other device is in the Active directory.

如果对我的问题有任何疑问,我很乐意回答,

If there are any questions about my question i am glad to answer them,

推荐答案

您可以获得运行在本地主机特定端口上的服务器的公共 URL.

You can get a public URL for your server running on a specific port on localhost.

在我的工作场所,我可以通过在应用程序中使用我机器的本地 IP 地址来访问本地服务器,正如大多数其他答案所建议的那样.但是在家里,由于某种原因,我无法做到这一点.在尝试了很多答案并花了很多时间之后,我发现了 https://ngrok.com.这是非常直接的.只需从文件夹中下载它:

At my work place I could access the local server by using the local IP address of my machine in the app, as most of the other answers suggest. But at home I wasn't able to do that for some reason. After trying many answers and spending many hours, I came across https://ngrok.com. It is pretty straight forward. Just download it from within the folder do:

ngrok portnumber

(来自 Windows 中的命令提示符)

( from command prompt in windows)

./ngrok portnumber

(来自 linux 终端)

(from terminal in linux)

这将为您提供在 localhost 上的该端口号上运行的本地服务器的公共 URL.您可以将其包含在您的应用中并使用该网址进行调试.

This will give you a public URL for your local server running on that port number on localhost. You can include in your app and debug it using that URL.

您可以安全地将本地网络服务器公开到互联网并捕获所有流量以进行详细检查.您可以与可能在远程工作并且可以调试应用/服务器交互的同事开发人员共享该 URL.

You can securely expose a local web server to the internet and capture all traffic for detailed inspection. You can share the URL with your colleague developer also who might be working remotely and can debug the App/Server interaction.

希望有一天这能节省某人的时间.

Hope this saves someone's time someday.

这篇关于通过wifi从android访问本地主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆