none
wcf Maintain Connection Between Client and WCF Service RRS feed

  • Question

  • Hello Friends

    I have Started Working on WCF Service, I am New in WCF Service. 

    I have To implement one Concept using WCF Service.

    i have web application and desktop application both login authentication is authenticated Via WCF Service. 

    Now Only 5 Client Can Connect or Authenticate In WCF Service. 

    so how can i maintain Channel, or any Connection mechanism That Holds the Connection Between Authenticated Client and Wcf service.

    Can Any one Suggest from where i can Start.

    thanks,

    Pradip 

    Monday, November 2, 2015 5:33 AM

Answers

  • Hi Makavanapradip,

    About how to start it. From my experience, normally I will write a sample, then I will

    to learn what is address, bindings, contract, endpoint and metadata etc. Next, to learn

    what is restful WCF Service and what is soap WCF Service, what different with each other.

    Next, to learn how to host a WCF Service Then, I will to learn what is security WCF Service,

    because this part is most difficult.

    For more information, please refer to the following articles:

    1.How to: Host and Run a Basic Windows Communication Foundation Service

    Best Regards,

    Grady

    Monday, November 2, 2015 9:26 AM
    Moderator

All replies

  • Hi Makavanapradip,

    According to your description, which binding do you used? And do you set the

    maxconnections in your web.config file?

    Like below:

    <bindings>
      <netTcpBinding>
        <binding 
                 closeTimeout="00:01:00"
                 openTimeout="00:01:00" 
                 receiveTimeout="00:10:00" 
                 sendTimeout="00:01:00"
                 transactionFlow="false" 
                 transferMode="Buffered" 
                 transactionProtocol="OleTransactions"
                 hostNameComparisonMode="StrongWildcard" 
                 listenBacklog="10"
                 maxBufferPoolSize="524288" 
                 maxBufferSize="65536" 
                 maxConnections="10"
                 maxReceivedMessageSize="65536">
          <readerQuotas maxDepth="32" 
                        maxStringContentLength="8192" 
                        maxArrayLength="16384"
                        maxBytesPerRead="4096" 
                        maxNameTableCharCount="16384" />
          <reliableSession ordered="true" 
                           inactivityTimeout="00:10:00"
                           enabled="false" />
          <security mode="Transport">
            <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
          </security>
        </binding>
      </netTcpBinding>
    

    Best Regards,

    Grady

    Monday, November 2, 2015 8:06 AM
    Moderator
  • Till now i havent add anything because i dont know any thing from where i want to start..
    Monday, November 2, 2015 8:13 AM
  • Hi Makavanapradip,

    About how to start it. From my experience, normally I will write a sample, then I will

    to learn what is address, bindings, contract, endpoint and metadata etc. Next, to learn

    what is restful WCF Service and what is soap WCF Service, what different with each other.

    Next, to learn how to host a WCF Service Then, I will to learn what is security WCF Service,

    because this part is most difficult.

    For more information, please refer to the following articles:

    1.How to: Host and Run a Basic Windows Communication Foundation Service

    Best Regards,

    Grady

    Monday, November 2, 2015 9:26 AM
    Moderator
  • ok just check my code

    Iservice.sc file

    [ServiceContract]
        public interface IService
        {
            [OperationContract]
            string getLoginStatus(string request, string username = "", string password = "");
            // TODO: Add your service operations here
        }

    Service.svc.sc

    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]

        public class Service : IService
        {
            static int noOfConnectedClient = 0;
            public string getLoginStatus(string request, string username = "", string password = "")
            {
                if (request != "logout")
                {
                    if (username.Trim() == "pradip" && password.Trim() == "pradip")
                    {
                        noOfConnectedClient+=1;
                        return "Sucess: " + noOfConnectedClient + " Client Connected";
                    }
                    else
                    {
                        return "Error: " + noOfConnectedClient + "Client Connected";
                    }
                }
                else
                {
                    noOfConnectedClient-=1;
                    return "Disconnect: " + noOfConnectedClient;
                }
            }

        }

    it is just about the Return how many client are connected. where number of connected client i stored in Static variable. but now mean while any client device internet disconnect then i want to get the connection status between client and WCF Service.



    Monday, November 2, 2015 9:48 AM
  • Hi Makavanapradip,

    Based on your code, I thought that is  no big issue, you can test it.

    Best Regards,

    Grady

    Tuesday, November 3, 2015 3:24 AM
    Moderator