0

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...

Tono Nam
  • 34,064
  • 78
  • 298
  • 470

3 Answers3

3

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.

scartag
  • 17,548
  • 3
  • 48
  • 52
  • Thanks about to try it soon! – Tono Nam Feb 26 '13 at 17:37
  • @scartag What might be happening if after changing the value to one second, the connection attempt last for at least 22. And then it throws an EndpointNotFoundException – Carlos487 May 22 '14 at 02:01
  • I have tried both and it doesn't seem to work. It will still wait for about 20 seconds in case the port is blocked by a firewall (for example) and then in the error message it displays the value from the configuration (2 seconds in your example) – Cesar Jan 15 '23 at 16:33
0

replace timeout in your bindingConfiguration NetTcpBinding_IService1

burning_LEGION
  • 13,246
  • 8
  • 40
  • 52
0

An answer for this has been given here wcf-channelfactory-and-opentimeout. It has something to do with sockets timeout. It seems that a workaround is needed.

Cesar
  • 130
  • 2
  • 7