Note that there are some explanatory texts on larger screens.

plurals
  1. POWCF Services issue? (2 way connection)
    primarykey
    data
    text
    <p>I have simple chat program using WCF service. One service use for server and another use for client. Those services connect to each other and call each other. For hosting server, I used a windows service and for client I host WCF service in a Windows app. After all I found that this code work on simple computer, but when move server service to another computer an exception raised and server can't connect to the client. I searched and try other ways. I get a result: *IF WCF SERVICE HOST IN WINDOWS APP U CAN'T CONNECT TO IT FORM ANOTHER COMPUTER. *THIS CODE WORKED ONLY WHEN I USED TWO WINDOWS SERVICES (hosting WCF client service in a windows service) But I want to know HOW hosting WCF service in windows app that can connect and work with another services? This is my code Client code: Manager.cs</p> <pre><code>public delegate void UserInfoHandeler(string UserName); public delegate void MessageHandeler(string Message); [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)] public class Manager : IClientPoint { public void SendUserList(string[] users) { frmRoom.Members = users; // this method called by Server (WCF service which host in windows service) //when server call this method I have an exception with SSPI } public void SendMessage(string message) { frmRoom.ReciveMessage = message; // this method called by Server (WCF service which host in windows service) //when server call this method I have an exception with SSPI } FrmJoin frmJoin; FrmRoom frmRoom; ChatServerClient ServiceInvoker; public string User { get; set; } public void Run() { frmJoin = new FrmJoin(); frmJoin.LoginEvent += new UserInfoHandeler(frmJoin_LoginEvent); ServiceInvoker = new ChatServerClient("WSHttpBinding_ChatServer", Settings.Default.ChatServerAddress); frmJoin.ShowDialog(); } void frmJoin_LoginEvent(string UserName) { frmRoom = new FrmRoom(); frmRoom.SendMessageEvent += new MessageHandeler(frmRoom_SendMessageEvent); frmJoin.LogoutEvent += new UserInfoHandeler(frmJoin_LogoutEvent); User = UserName; frmRoom.ReciveMessage = ServiceInvoker.Login(User, Settings.Default.ClientPointAddress); frmRoom.ShowDialog(); } void frmJoin_LogoutEvent(string UserName) { string message = ServiceInvoker.Logout(UserName, Settings.Default.ChatServerAddress); } void frmRoom_SendMessageEvent(string Message) { ServiceInvoker.SendMessage(User, Message); } } </code></pre> <p>Client config:</p> <pre><code>&lt;system.serviceModel&gt; &lt;bindings&gt; &lt;wsHttpBinding&gt; &lt;binding name="WSHttpBinding_Config" closeTimeout="00:05:00" openTimeout="00:05:00" receiveTimeout="00:10:00" sendTimeout="00:05:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Mtom" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false"&gt; &lt;readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /&gt; &lt;reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" /&gt; &lt;security mode="Message"&gt; &lt;transport clientCredentialType="Windows" proxyCredentialType="None" realm="" /&gt; &lt;message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" establishSecurityContext="true" /&gt; &lt;/security&gt; &lt;/binding&gt; &lt;binding name="MyConfig" closeTimeout="00:10:00" openTimeout="00:10:00" sendTimeout="00:10:00" maxReceivedMessageSize="2147483647"&gt; &lt;readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /&gt; &lt;/binding&gt; &lt;/wsHttpBinding&gt; &lt;/bindings&gt; &lt;client&gt; &lt;endpoint binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_Config" contract="Host.IChatServer" name="WSHttpBinding_ChatServer"&gt; &lt;/endpoint&gt; &lt;/client&gt; &lt;behaviors&gt; &lt;serviceBehaviors&gt; &lt;behavior name="Room.Service1Behavior"&gt; &lt;serviceMetadata httpGetEnabled="true" /&gt; &lt;serviceDebug includeExceptionDetailInFaults="false" /&gt; &lt;/behavior&gt; &lt;/serviceBehaviors&gt; &lt;/behaviors&gt; &lt;services&gt; &lt;service behaviorConfiguration="Room.Service1Behavior" name="Room.Manager"&gt; &lt;endpoint address="" binding="wsHttpBinding" contract="Room.IClientPoint" bindingConfiguration="WSHttpBinding_Config"&gt; &lt;/endpoint&gt; &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /&gt; &lt;/service&gt; &lt;/services&gt; </code></pre> <p> <a href="http://PChost:8731/ClientPoint/" rel="nofollow noreferrer">http://PChost:8731/ClientPoint/</a> <a href="http://PCserver:8731/ChatServer/" rel="nofollow noreferrer">http://PCserver:8731/ChatServer/</a> </p> <p>Server code: [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)] public class ChatServer : IChatServer { Dictionary clients;</p> <pre><code> public ChatServer() { clients = new Dictionary&lt;string, ClientInvoker&gt;(); } public string Login(string Username, string address) { try { ClientInvoker client = new ClientInvoker("WSHttpBinding_ClientPoint", address); clients.Add(Username, client); foreach (ClientInvoker clientinvoker in clients.Values) clientinvoker.SendUserList(clients.Keys.ToArray()); } catch (Exception e) { File.AppendAllText(@"c:\ServiceChatLog.txt", "Service trow Exeption \n"); File.AppendAllText(@"c:\ServiceChatLog.txt", e.ToString() + " \n"); } return string.Format("Welcom {0}", Username); } public string[] GetListUser() { return clients.Keys.ToArray(); } public void SendMessage(string userName, string ReciveMessage) { string message = string.Format("{0} : {1}", userName, ReciveMessage); foreach (ClientInvoker clientinvoker in clients.Values) clientinvoker.SendMessage(message); } public string Logout(string Username, string address) { clients.Remove(Username); foreach (ClientInvoker clientinvoker in clients.Values) { clientinvoker.SendUserList(clients.Keys.ToArray()); clientinvoker.SendMessage(string.Format("{0} left ROOM", Username)); } return string.Format("Godbye {0}", Username); } } </code></pre> <p>Server config:</p> <p> </p> <pre><code> &lt;/binding&gt; &lt;/wsHttpBinding&gt; &lt;/bindings&gt; &lt;client&gt; &lt;endpoint binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_Config" contract="Room.IClientPoint" name="WSHttpBinding_ClientPoint"&gt; &lt;/endpoint&gt; &lt;/client&gt; </code></pre> <p></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload