Question

I have a wcf service that works fine. The problem is the client. I have a little gui where the user is supposed to place the ip address of where the wcf service is located. Both the client and service are on the same network so if I am not able to connect it is because I provided an incorrect ip address or because the firewall is blocking. Anyways how can I shorten that time so that if the user types the incorrect ip he does not have to wait like 20 seconds? Here is how my app.config file looks for my client:

Here is how my client app.config file looks:

    <client>
        <endpoint address="net.tcp://127.0.0.1:41236/" binding="netTcpBinding" 
            bindingConfiguration="NetTcpBinding_IService1" contract="ServiceReference1.IService1"
            name="NetTcpBinding_IService1">
            <identity>
                <dns value="localhost" />
            </identity>
        </endpoint>
    </client>

Edit

I have updated my app.config file to:

    <bindings>
        <netTcpBinding>
            <binding name="NetTcpBinding_IService1" sendTimeout="00:00:02" receiveTimeout="00:00:02">
                <security mode="Transport" />
            </binding>
        </netTcpBinding>
    </bindings>
    <client>
        <endpoint address="net.tcp://10.10.1.154:41236/" 
                  binding="netTcpBinding" 
                  bindingConfiguration="NetTcpBinding_IService1" 
                  contract="ServiceReference1.IService1"

            name="NetTcpBinding_IService1">
            <identity>
                <dns value="localhost" />
            </identity>
        </endpoint>
    </client>

note I am placing an ip address that does not exist on purpose and for some reason the program still waits for like 10 seconds... I added sendTimeout="00:00:02" receiveTimeout="00:00:02" attributes and still did not work :(

Edit 2

Here is the error message that I get:

Could not connect to net.tcp://10.10.1.154:41236/. The connection attempt lasted for a time span of 00:00:21.0342031. TCP error code 10060: 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 10.10.1.154:41236.

Note it attempted to connect for 21 seconds... I knew I was not going to be able to connect but it will be nice if I could reduce that time. I am planning to use this program on the same network...

Was it helpful?

Solution

On your NetTcpBinding_IService1 bindingConfiguration

add an attribute sendTimeout="00:00:02"

This will reduce it to 2 seconds.

Edit

Please use OpenTimeout="00:00:02" this should work.

OTHER TIPS

replace timeout in your bindingConfiguration NetTcpBinding_IService1

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top