我使用WSHttpBinding创建了WCF服务:
ServiceHost svh = new ServiceHost(typeof(MyService));
var httpLocation = "http://" + address + ":4041";
svh.AddServiceEndpoint(typeof(IMyService), new WSHttpBinding(SecurityMode.None), httpLocation);
svh.Open();
我在
系统中注册了它netsh http add urlacl url=http://+:4041/ user=username
当我尝试从localhost连接到它时,该服务正常运行。
但是当我把它放在另一台电脑上时(地址='localhost'或地址='ip-of-the-machine'),连接失败并出现以下异常:
There was no endpoint listening at http://192.168.44.128:4041/ that could accept
the message. This is often caused by an incorrect address or SOAP action. See
InnerException, if present, for more details.
内部异常:
A connection attempt failed because the connected party did not properly respond
after a period of time, or established connection failed because connected host
has failed to respond 192.168.44.128:4041
我已尝试将该服务添加到防火墙,但没有帮助。
这里有什么问题?
更新
以下是来自netstat -ano
的相关信息。第一个是http端点,它不能从外部连接,第二个是net.tcp端点,工作正常:
TCP [::]:4041 [::]:0 LISTENING 4
TCP 192.168.44.128:9939 0.0.0.0:0 LISTENING 2120
答案 0 :(得分:1)
在命令行提示符下使用“NETSTAT -ano”验证您的服务正在侦听指定的端口。检查完毕后,尝试从客户端框中点击您的服务盒IP。如果两者都成功,您很可能会查看防火墙和/或网络交换机配置问题。