Solved

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

Posted on 2016-08-12
6
49 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 81

Expert Comment

by:David Johnson, CD, MVP
ID: 41755214
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
ID: 41756127
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 81

Expert Comment

by:David Johnson, CD, MVP
ID: 41756235
is port 8000 open on the firewall on Victoria6?
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
LVL 1

Author Comment

by:WestcountryBusiness
ID: 41759034
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
ID: 41765071
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
ID: 41772824
Solution found elsewhere on the Internet & posted here for reference
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

740 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