<blockquote>
  <p>See also <a href="https://stackoverflow.com/questions/1700917/how-does-a-wcf-server-inform-a-wcf-client-about-changes-better-solution-then-si">How does a WCF server inform
  a WCF client about changes? (Better
  solution then simple polling, e.g.
  Coment or long polling)</a></p>
</blockquote>

<p>I need to use push-technology with WCF through client firewalls. This must be a common problem, and I know for a fact it works in theory (see links below), but I have failed to get it working, and I haven't been able to find a code sample that demonstrates it.</p>

<p>Requirements: </p>

<ul>
<li>WCF</li>
<li>Clients connects to server through tcp port 80 (netTcpBinding).</li>
<li>Server pushes back information at irregular intervals (1 min to several hours).</li>
<li>Users should not have to configure their firewalls, server pushes must pass through firewalls that have all inbound ports closed. TCP duplex on the same connection is needed for this, a dual binding does not work since a port has to be opened on the client firewall.</li>
<li>Clients sends heartbeats to server at regular intervals (perhaps every 15 mins) so server knows client is still alive.</li>
<li>Server is IIS7 with WAS.</li>
</ul>

<p>The solution seems to be duplex netTcpBinding. Based on this information:</p>

<p><a href="http://blogs.msdn.com/drnick/archive/2006/05/01/configuring-wcf-for-nats-and-firewalls.aspx" rel="nofollow noreferrer">WCF through firewalls and NATs</a></p>

<p><a href="http://blogs.msdn.com/drnick/archive/2006/10/20/keeping-connections-open-in-iis.aspx" rel="nofollow noreferrer">Keeping connections open in IIS</a></p>

<p>But I have yet to find a code sample that works.. I've tried combining the "Duplex" and "TcpActivation" samples from Microsoft's WCF Samples without any luck. Please can someone point me to example code that works, or build a small sample app. Thanks a lot!</p>

[{'answer_id': 22835, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 1, 'selected': False, 'text': "<p>In most firewall setups, the TCP connection will be torn down by the firewall if it is idle to conserve resources. The idle timeout is probably not something you can control. Some will tear them down if they are idle and a resource limit is being hit.</p>\n\n<p>Most corp environments won't allow any machines to make an outbound TCP connection anyway.</p>\n\n<p>Also, using this mechanism means you are going to have scaling problems. I think more reliable solution is to queue up information and have your clients poll for them regularly. Utilize caching if possible such that a subsequent client poll will get the cached data from the customers proxy cache, if they are using one.</p>\n\n<p>If you have to push data in a timely manner, in sub-second land (i.e. financial services), then consider some messaging infrastructure such an NServiceBus distributor on client side, but that will require a customer install...</p>\n\n<p>So have you tried using Toredo? Having read that it would appear there it is prob too complicated for a user to setup.</p>\n"}, {'answer_id': 195141, 'author': 'smaclell', 'author_id': 22914, 'author_profile': 'https://Stackoverflow.com/users/22914', 'pm_score': 1, 'selected': False, 'text': '<p>I have not tried the scenario you speak of so I can\'t be too much help, sorry. If all you need to bypass is the client firewall you might want to check out <a href="https://stackoverflow.com/questions/113755/programmatically-add-an-application-to-windows-firewall">this post</a>. </p>\n\n<p>Good luck.</p>\n'}, {'answer_id': 199129, 'author': 'marcj', 'author_id': 23940, 'author_profile': 'https://Stackoverflow.com/users/23940', 'pm_score': 2, 'selected': False, 'text': '<p>Have you tried looking at: <a href="http://www.codeproject.com/KB/WCF/WCF_Duplex_UI_Threads.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/WCF/WCF_Duplex_UI_Threads.aspx</a></p>\n\n<p>Can you provide examples of what you have already attempted? With details of firewalls etc, error messages?</p>\n\n<p>If both client and server can be addressed directly and firewalls are not an issue, have you considered allowing clients to register a URL providing a supported contract. The server can then call this service whenever it needs to, without the need to establish a long running (but mostly idle connection), avoids the need for heart beating and can be made resilient across sessions\\connections.</p>\n'}, {'answer_id': 204036, 'author': 'Sire', 'author_id': 2440, 'author_profile': 'https://Stackoverflow.com/users/2440', 'pm_score': 4, 'selected': True, 'text': '<p>I\'ve found a couple of solutions:</p>\n\n<p><a href="http://www.zeroc.com/" rel="nofollow noreferrer" title="ZeroC Ice">ZeroC Ice</a> GPL with a commercial option. Have only tested quickly. Looks more powerful than .NET Remoting and is very actively developed.</p>\n\n<p><a href="http://www.remobjectssdk.com/" rel="nofollow noreferrer" title="RemObjects">RemObjects</a> Commercial, active development, supports everything but does not seem to have all the more advanced features that GenuineChannels use.</p>\n\n<p><a href="http://www.genuinechannels.com/" rel="nofollow noreferrer" title="GenuineChannels">GenuineChannels</a>. It uses remoting with a lot of nice added features, the most important one being it works through NATs without the need to open the client firewall. Unfortunately seems to be very dead.</p>\n\n<p>Another solution is to use streaming with IIS, according to this article: <a href="http://blogs.msdn.com/drnick/archive/2006/10/20/keeping-connections-open-in-iis.aspx" rel="nofollow noreferrer" title="Keeping connections open in IIS">Keeping connections open in IIS</a></p>\n\n<p>The client makes the first connection (http with IIS6, tcp with IIS7) to the server at port 80, the connection is then kept open with a streaming response that never ends.</p>\n\n<p>I haven\'t had the time to experiment with this, and I haven\'t found a sample that says it specifically solves the firewall-problem, but here\'s an excellent sample that probably works: <a href="http://blogs.thinktecture.com/buddhike/archive/2007/05/23/414851.aspx" rel="nofollow noreferrer">Streaming XML</a>. </p>\n'}, {'answer_id': 1610886, 'author': 'chenz', 'author_id': 130094, 'author_profile': 'https://Stackoverflow.com/users/130094', 'pm_score': 1, 'selected': False, 'text': '<p>Have you tried this one? \n<a href="http://code.msdn.microsoft.com/duplexhttp" rel="nofollow noreferrer">DuplexHttpBinding</a></p>\n\n<p>It is using smart polling technique encapsulated as custom WCF binding. So it should work out of the box.</p>\n'}, {'answer_id': 2498205, 'author': 'RockWorld', 'author_id': 185550, 'author_profile': 'https://Stackoverflow.com/users/185550', 'pm_score': -1, 'selected': False, 'text': '<p>You can do following change in client for accessing duplex web service on Firewall enabled client.</p>\n\n<ul>\n<li>Set WebHttp option checked in Firewall -> Advanced -> Settings (of Network Connection Setting) -> Web Server (Http)</li>\n</ul>\n'}]
['https://Stackoverflow.com/questions/22340', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2440/']