Solved

WCF - Client connecting OK when LocalHost but Timeout when connecting remotely

Posted on 2016-08-12
6
21 Views
Last Modified: 2016-08-27
I have a WCF service running with separate client software that connects to it.  All works fine in development when on one PC.  Also works fine in Live as long as client running on the same computer as WCF service but fails with timeout when connecting remotely.  I tried on two different 'live' environments and completely disabled the firewall (while testing) in both cases.

Here's the code that works locally:

 
Dim WithEvents CommsServerCallback As New AutomatedWeighbridgeInterventionCallback
Dim objClient As InterventionServiceReference.IInterventionService
Dim EndPointAddress As String
If Testing Then EndPointAddress = "http://localhost:8000/InterventionService/" Else EndPointAddress = "http://WCFServerPC:8000 InterventionService/"
Dim iCntx As New InstanceContext(CommsServerCallback)
Dim MyBinding As New WSDualHttpBinding
MyBinding.SendTimeout = New TimeSpan(0, 0, 30)
Dim MyEndPoint As New EndpointAddress(EndPointAddress)
Dim myChannelFactory As DuplexChannelFactory(Of IInterventionService) = New DuplexChannelFactory(Of IInterventionService)(iCntx, MyBinding, MyEndPoint)
objClient = myChannelFactory.CreateChannel()
 Try
      If Not objClient.SubscribeClient() Then Throw New Exception("Unable to Connect")
Catch ex As Exception
      Throw ex
End Try

Open in new window


When this runs on the same computer as the WCF service (name: WCFServerPC), both endpoints declared above work.  When this runs on a separate PC on the same network, it fails with a timeout at 'objClient.SubscribeClient()'.  Firewall is disabled.  What am I missing?  (e.g. is there some 'AllowRemoteConnections=False' setting in the app config somewhere or similar?)
0
Comment
Question by:WestcountryBusiness
  • 4
  • 2
6 Comments
 
LVL 78

Expert Comment

by:David Johnson, CD, MVP
Comment Utility
Dim objClient As InterventionServiceReference.IInterventionService
Dim EndPointAddress As String
If Testing Then EndPointAddress = "http://localhost:8000/InterventionService/" Else EndPointAddress = "http://WCFServerPC:8000 InterventionService/""http://WCFServerPC:8000/InterventionService/"
0
 
LVL 1

Author Comment

by:WestcountryBusiness
Comment Utility
Hi David, thanks for your comment. Unfortunately that missing / was a typo when I copied the code to this post.  I tried to simplify it a little and changed the server host name for clarity (& got it wrong!).  In the live application, that line actually reads:
If LocalServer = "VICTORIA6" Then EndPointAddress = "http://Victoria6:8000/InterventionService/" Else EndPointAddress = "http://localhost:8000/InterventionService/"

Open in new window

Where Victoria6 is the actual host name of the PC.  Sorry for the error but the URL is correct so that's not the cause of this issue.
0
 
LVL 78

Expert Comment

by:David Johnson, CD, MVP
Comment Utility
is port 8000 open on the firewall on Victoria6?
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 1

Author Comment

by:WestcountryBusiness
Comment Utility
Sorry for delay in replying.  Yes the port is open, and I've specifically allowed the exe and I've tried with the firewall completely off.  My initial thoughts were a firewall issue but I think that rules it out (correct me if I'm wrong).

I'm struggling to debug this.  I've tried to telnet into the server on that port but get not connection, but then I'm not sure if I should.  Is there any testing I can do to track down whether its a communication issue (network, firewall etc.) or a configuration issues (something in the app.config or similar of the WCF server program)?

Thanks
0
 
LVL 1

Accepted Solution

by:
WestcountryBusiness earned 0 total points
Comment Utility
OK, found the solution.  Basically it was the use of wsDualHttpBinding as that opens a return port to the client so requiring firewall changes to the client as well as the server.  The best fix was to use net TCP binding.

Thanks to this excellent artical that finally offered the solution:
http://www.dotnetconsult.co.uk/weblog2/PermaLink,guid,b891610a-6b78-4b54-b9a6-4ec81c82b7c0.aspx
0
 
LVL 1

Author Closing Comment

by:WestcountryBusiness
Comment Utility
Solution found elsewhere on the Internet & posted here for reference
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now