我在VS2013中使用的是Grapevine3.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?
发布于 2016-05-26 00:11:49
我甚至为这个程序制定了一个Windows防火墙规则
您是否为端口设置了Windows防火墙规则?如果不是,则返回。您可能需要将url添加到运行该url的计算机上的ACL中,这可以通过以admin身份打开终端并运行以下命令来实现:
netsh http add urlacl url=http://*:1234/ user=Everyone
https://stackoverflow.com/questions/37382705
复制相似问题