【发布时间】:2016-09-19 20:16:43
【问题描述】:
我在 VS2013 中使用 Grapevine 3.1.0。该项目名为 ConsoleApplication1。
在我的主机上启动服务器后,我可以从localhost:1234、127.0.0.1:1234和192.168.1.2:1234(我的机器的本地IP地址)在本地访问它。但是,即使在端口转发之后,我也无法从任何机器连接到我的外部 IP。此外,我无法从另一台机器连接本地 IP 地址,只能从主机连接。
我什至为该程序制定了 Windows 防火墙规则,但无济于事。
以下代码用于服务器部分。使用 Firefox 尝试连接。
//Program.cs
using System;
using System.Net;
using Grapevine.Server;
class Program
{
static void Main(string[] args)
{
var server = new RESTServer(host: "*");
server.Start();
Console.ReadLine();
server.Stop();
}
}
public sealed class TestResource : RESTResource
{
[RESTRoute]
public void HandleAllGetRequests(HttpListenerContext context)
{
SendTextResponse(context, "GET is a success!");
}
}
netstat -a 报告服务器正在侦听。尝试从同一网络上的另一台计算机连接时,我收到来自 Firefox 的超时消息。使用 Fiddler 查看主机和另一台机器,我可以看出主机在尝试建立连接后从未收到任何形式的消息。
我确保我在管理员模式下运行程序,但如果我不这样做,它会抛出异常。
我已经在 Windows 8.1 和 Windows 7 上测试了服务器。
为了成功运行 Grapevine,我还需要执行哪些额外步骤?
【问题讨论】:
-
您在哪个版本的 Windows 上运行应用程序?
-
我已经更新了上面的帖子。我已经在 Windows 8.1(主)和 Windows 7 上测试了服务器。
-
您是从 Visual Studio 运行应用程序,还是作为独立的可执行文件运行?
-
我正在运行构建默认发布配置时生成的可执行文件(ConsoleApplication1.exe,而不是 ConsoleApplication1.vshost.exe)。