为什么我无法通过我的iPhone访问在我的Mac上运行的网络应用程序? [英] Why can't I access a web app running on my Mac via my iPhone?

查看:212
本文介绍了为什么我无法通过我的iPhone访问在我的Mac上运行的网络应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个拥有网络组件的iPhone应用程序。我正在开发Java应用程序(Google App Engine),运行在8080端口。当我在iPhone模拟器中测试我的应用程序时,它的工作原理。



但是现在我试图在设备上测试,我不能打我的Jetty实例。我可以通过iPhone访问我的Mac,因为我可以点击 http://10.0.1.7/~brianpapa / ,并在Web Sharing打开时查看我的主文件夹。但是当我尝试点击 http://10.0.1.7:8080/ 时,它说它不能连接到服务器。



有趣的是,如果我尝试点击 http://10.0 .1.7:8080 / 从我的mac,它不起作用 - 我必须使用localhost作为主机名,那么没关系。有没有人曾经遇到过,并且知道如何解决它?

解决方案

您需要将服务器绑定到您的外部IP地址。请参阅文档


- address = ...

用于服务器的主机地址。您可能需要将其设置为能够从网络上的其他计算机访问开发服务器。地址0.0.0.0允许本地主机访问和主机名访问。默认是localhost。



I'm developing an iPhone app that has a network component. I'm developing the app in Java (Google App Engine actually), running on port 8080. And it works, when I test my app in the iPhone simulator.

But now I am trying to test on the device, and I can't hit my Jetty instance. I can certainly access my Mac via the iPhone because I'm able to hit http://10.0.1.7/~brianpapa/ and view my Home Folder when Web Sharing is turned on. But when I try to hit http://10.0.1.7:8080/, it says it can't connect to the server.

Interestingly, if I try to hit http://10.0.1.7:8080/ from my mac, it doesn't work either - I have to use localhost as the hostname instead, then it's fine. Has anybody ever encountered this before, and know how to fix it?

解决方案

You need to bind the server to your external ip address. See the docs:

--address=...
The host address to use for the server. You may need to set this to be able to access the development server from another computer on your network. An address of 0.0.0.0 allows both localhost access and hostname access. Default is localhost.

这篇关于为什么我无法通过我的iPhone访问在我的Mac上运行的网络应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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