0
我在做应用程序内聊天的实现,所以我发现非常有用的文章由 作者:Ger Hayden(初学者指南Duplex WCF)。 下面的文章,我的聊天开始工作非常快(服务器和客户端在同一台PC上) 一切都很好,直到我在测试机器上部署聊天服务器。 在服务器端实现当WCF System.Diagnostics程序,我发现:WCF回调(客户端不在DNS)没有端点侦听..(求助)
- 客户端与服务器
- 服务器试图执行回调建立连接,但是失败例外:
- 有没有终点 在听 http://a2200492.m022/Temporary_Listen_Addresses/00bc713c-e37c-4f98-adb6-4dff5b523126/25fb8f22-53dd-408e-8189-e1d3850344e6 可以接受该消息。这通常是由不正确的地址或SOAP操作导致的。有关更多 的详细信息,请参阅InnerException(如果存在)。
- 远程名称无法解析:a2200492.m022“
问题是,我的PC(客户端)又名a2200492.m022不在DNS中,因此服务器无法创建高分辨率计算机名称 - > IP。 我正在寻找解决方案来配置WCF使用IP而不是计算机名称,但我没有找到这样的配置参数。 (如果有人请让我知道) 接下来我从有类似问题的人,想将PC添加到DNS,或添加到服务器主机文件的想法。但我想要一般解决方案。 所以,这工作溶液(或更好的解决方法)是(从后面的代码把当前客户端IP): 客户端代码:
//In method for connecting...
System.ServiceModel.Channels.Binding b = new WSDualHttpBinding("WSDualHttpBinding_Server");
string clientID = Guid.NewGuid().ToString().Replace("-", ""); //if 2 app on same IP
/////////////////////////////////////////
//here is line that solved my problem, let server make callback to my ip
(b as WSDualHttpBinding).ClientBaseAddress = new Uri(@"http://" + MyIp() + "/" + clientID);**
/////////////////////////////////////////
(b as WSDualHttpBinding).ReliableSession = new ReliableSession(){Ordered=true};
(b as WSDualHttpBinding).Security = new WSDualHttpSecurity() { Mode = WSDualHttpSecurityMode.None };
(b as WSDualHttpBinding).HostNameComparisonMode = HostNameComparisonMode.WeakWildcard;
//ServerIP
EndpointAddress serverIp = new EndpointAddress(System.Configuration.ConfigurationManager.AppSettings["ChatServer"].ToString());
//Instantiate service reference
chatServer = new ChatServerRef.ServerClient(new InstanceContext(this), b, serverIp);
//Next step is call method JoinTheConversation on chatServer