Home » Asp.net

Peer to peer applications

Am facing a problem in developing peer to peer appln.

first of all a machine has two ips(one private visible in intranet like and second public ip visible in internet i need to connect to a peer located at remote place with the same criteria(two ips).The problem is i cnt go through the public ip to internal ip.On reading some articles on net i came to know the technique used to connect through public ip to private ip is termed as "HOLE PUNCHING"/"PORT FORWARDING".can some one help me on this issue? r is there any alternative other than this.I have to do it programmatically not manually.




3 Answers Found


Answer 1

Am facing  a problem  in developing peer  to peer appln.
Presumably you are using Windows Forms rather than ASP.NET.  If so, you need to seek help on the MSDN Forums, not the ASP.NET Forums.

Answer 2

This is not a problem  related to .NET, it has to do with your network setup. I might suggest Port Forwarding or using DMZ.

Answer 3

I am replying quite late but i have somethings to share. Hole punching is a nice concept to use in P2P applications. It effectively handles the problem  of Ipv4 and ipv6 and NATs and firewalls..... u can refer this link http://www.brynosaurus.com/pub/net/p2pnat/    (Mostly UDP hole punching is used...)

I have a full application developed using P2P UDP holepunching concept. But I am facing  a problem.. The networking people have blocked the outgoing ports also through firewall... and my application requires them to be open... can anyone help how to solve this problem???



In SQL 2008 R2, I understand that Peer-to-Peer replication can provide a unique opportunity.

I'm currently looking to understand if this capability feeds into an application architecture I'm beginning to research a concept for.

My firm is a medical device manufacturer. We are looking to build a new medical device gateway. This gateway is pretty simple in that medical devices connect to the gateway to transfer device operation information (little (1000 character) XML formatted messages, several hundred messages per minute).

In our legacy design, we have N+1 application servers, load balanced, that the medical devices communicate to. These gateway application servers send and receive XML messages to the device, and persist the messages into an Oracle 10g database (boo hiss!)

The current architecture is redundant at the application server level with load balancing, but the DB is the single point of failure.

In drawing up a concept of a new gateway, I was thinking of a design where each node of the application gateway consisted of the application services for device communications as well as MS SQL 2008 R2 Std  configured as peer to peer replication between each node (two, three, or maybe four nodes max).

So my thought was to use load balancing to have a device connect to a node in my new gateway, transmit the XML status message, have it hit that nodes MSSQL2008 R2 and disconnect. That node's MSSQL2008 R2 engine would replicate that message to the other nodes in my Gateway farm (again a max of three or four depending upon design).

So in any case, each application server is a complete, self-contained gateway. if a node fails or is taken off line, the remaining node has full service ability to the medical devices, outside of perhaps some communication congestion issues that may result with a node failure.

Is this a feasable architecture?

My goal is to build in redundancy at the application communication layer between devices and nodes, with load balancing, but to ensure that the DB is redundant as well.

I thought about building a standalone DB with Active/Passive failover capability as traditional DB architectures allow.

The ability to create a Gateway appliance with a database loaded on each node that peer-to-peer replicates is an intriguing thought. I'm wondering if we can build a Gateway appliance, running W2k8R2 and SQL2008 R2 Std. For redundancy, add another Gateway appliance, use Peer-to-Peer SQL replication, put a load balancer in front of them (Citrix, Cisco) to achieve both application and DB fault tolerance. If one node goes down, the other provides complete service ability.

I'm wondering what the practical realities of this type of design is, if any one has used it similarly, and what the caveats would be.


Am facing a problem in developing peer to peer appln.

first of all a machine has two ips(one private visible in intranet like and second public ip visible in internet i need to connect to a peer located at remote place with the same criteria(two ips).The problem is i cnt go through the public ip to internal ip.On reading some articles on net i came to know the technique used to connect through public ip to private ip is termed as "HOLE PUNCHING"/"PORT FORWARDING".can some one help me on this issue? r is there any alternative other than this.I have to do it programmatically not manually.




       I am implementing the MS Sync Framework for Peer to Peer sync of Sql Server database. I am following the example 'WebSharingAppDemo-SqlProviderEndToEnd' at the : http://code.msdn.microsoft.com/sync  which works well when the Peers are not behind the NAT.

But I have to sync between the peers where both end peers are behind the NAT. And I see the WCF doesn't work behind the NAT.

I am planning to use the .Net Remoting using Genuine Channels for transport of the sync. But I have no proper direction regarding how to expose the SyncProviders over the .net remoting.

Can anybody, please guide me implementing the Sync Framework over the .Net Remoting. Any samples would be appreciated.



can I use a service using a netPeerTcpBinding enpoint hosted under WAS using Windows 2008 R2? I see posts that this is not working well when hosted in WAS.
My name is Sean Kelley and I am a Program Manager for the Sync Framework team.  Microsoft Sync Framework is a comprehensive synchronization platform that enables collaboration and offline access for applications, services, and devices.  Microsoft Sync Services for ADO.NET is a part of Sync Framework. Modeled after the ADO.NET data access APIs, the Sync Services API provides an intuitive way to synchronize databases.  This walkthrough focuses on a collaboration scenario.  This is a scenario in which two or more databases can be synchronized peer-to-peer without having to go through a central hub. This kind of solution is useful when remote workers (such as on-site financial auditors) work as a group in a remote location. These workers must frequently share information among one another. However, because they do not have connectivity to the central database, they must share information through some kind of peer-to-peer network.

I am looking for feedback regarding the complexity of this walkthrough and where you think VS tooling might help.  Also, it would be interesting to hear back regarding real-world scenarios where you would find this useful.  Note that if you are interested in learning more about the Microsoft Sync Framework, please feel free to visit our MSDN portal below:


Thanks and have fun!

Sean Kelley
Program Manager


Ok, so right now I'm sketching out the basic outline for a game I'm developing. It is going to be a multiplayer game where everyone basically has their own "realm" which is interconnected to several other realms, some are AI-based and the rest are other player "realms". A handful of servers would handle the interconnectivity between player realms so they can travel from one to another.


The game won't need to do any file transfers or anything. I was wondering if the Microsoft Peer-to-Peer technology would be adequate so that the game could operate so that players can still connect to other realms regardless of whether or not one player realm is up or down. Instead of a traditional client/server MMO game, I want to try and develop a game that is fairly dynamic when it comes to interconnectivity so that no matter what, there is another "realm" for a player to visit if a desired "realm" is down.


Thanks in advance!




I have been trying to develop a peer to peer application that uses Micosoft's Peer to Peer Group library. Basing my work on the Creating a Group Chat Application acrticle on msdn. This works fine for local groups and will also work for global groups if I have a thrid party tunnel adapter installed such as the gogo6 client. However from a few things I have read it seems like I should be able to get things working through the Teredo tunnel adapter that comes built into Windows.

I have tried various things and can now access ipv6 only sites (eg ipv6.google.com) without the gogo6 tunnel running, but I can't seem to find any other peers in my global group through this method.

I have added a rule allowing trafic (including edge traversal) for the application in the Windows Firewall and also opened the following ports to incoming and outgoing trafic.

tcp 3587 udp 3540, 1900

From the samples I have read it seems like it should just work, but it doesn't. I did read that to use teredo in an application you had to specificaly enable it. The only way I have found to do this is when opening the socket, but the group api does all of that for you so I have no known way of controlling that.


I have put together a 1-way (download) peer-to-peer sync app between 2 SQL Server databases that uses custom DbSyncProviders and custom adapters. The app is straightforard with one exception - I am passing a custom parameter to my UpdateMetaData command that represents a type of versioning; the param is guid that I use basically as a signature to detect "version differences" between peers.

 My tracking tabl looks like:

 CREATETABLE Sync.Customer_Tracking


    CustomerId uniqueidentifier NOTNULLPRIMARYKEY   

    , update_scope_local_id intNULL

    , scope_update_peer_key int

    , scope_update_peer_timestamp bigint

    , local_update_peer_key int

    , local_update_peer_timestamp timestamp

    , create_scope_local_id intNULL

    , scope_create_peer_key int

    , scope_create_peer_timestamp bigint

    , local_create_peer_key int

    , local_create_peer_timestamp bigint

    , sync_row_is_tombstone int

    , restore_timestamp bigint

    , last_change_datetime datetimedefault NULL

    , [signature] uniqueidentifier



 My UpdateMetaData stored proc is straightforward and simpy updates my tracking table normally with the exception of also updating my [Signature] field which is also on the tracking table on the source peer.

MY MAIN CONFUSION is HOW the value of [Signature] gets passed to this stored proc? It works and the [Signature] value gets updated in the tracking table on my destination peer when records are synched from the source peer. I am *not* passing the value via my app code; the call to the proc is coded in my custom adapter like:

adapterCmd = newSqlCommand();

adapterCmd.CommandType = CommandType.StoredProcedure;

adapterCmd.CommandText = "Sync.Customer_insertmetadata";

adapterCmd.Parameters.Add( "@CustomerId", SqlDbType.BigInt );

adapterCmd.Parameters.Add( "@" + DbSyncSession.SyncScopeLocalId, SqlDbType.Int );

adapterCmd.Parameters.Add( "@" + DbSyncSession.SyncRowIsTombstone, SqlDbType.Int );

adapterCmd.Parameters.Add( "@" + DbSyncSession.SyncCreatePeerKey, SqlDbType.Int );

adapterCmd.Parameters.Add( "@" + DbSyncSession.SyncCreatePeerTimestamp, SqlDbType.BigInt );

adapterCmd.Parameters.Add( "@" + DbSyncSession.SyncUpdatePeerKey, SqlDbType.Int );

adapterCmd.Parameters.Add( "@" + DbSyncSession.SyncUpdatePeerTimestamp, SqlDbType.BigInt );

adapterCmd.Parameters.Add( "@" + DbSyncSession.SyncCheckConcurrency, SqlDbType.Int );

adapterCmd.Parameters.Add( "@" + DbSyncSession.SyncRowTimestamp, SqlDbType.BigInt );

adapterCmd.Parameters.Add( "@signature", SqlDbType.UniqueIdentifier, 16 );

adapterCmd.Parameters.Add( "@" + DbSyncSession.SyncRowCount, SqlDbType.Int ).Direction = ParameterDirection.Output;

In the SelectChanges command on my source peer, I do include in my Select list the [Signature] value from the source tracking table, although I can't seem to confirm that the value comes from here when synched on the destination peer. Can someone tell me precisely how the value for a *custom* parameter to an UpdateMetaData command is passed? Although the sample I set up works, I'm not sure how the value is being passed to my custom [signature] paramter, and that makes me feel a little uneasy about my sopution.


Now this is where things get really wierd - in my sample app used above, my base table uses a uniqueidentifier field as the PK on the table. IF I CHANGE this field to be a BigInt and an *IDENTITY* field, then the updating of my [signature] field in my UpdateMetaData proc on my destination peer fails and for some odd reason I can't explain, my @signature parameter is now passed in a NULL value. What was working in the previous example now fails by passing NULL for my [Signature] parameter when I move to using an IDENTITY field as my PK field. In my Insert comand, I turn IDENTITY_INSERT ON and OFF like:






      , CustomerName

      , SalesPerson

      , CustomerType





      , @CustomerName

      , @SalesPerson

      , @CustomerType




And now the @Signature param to the UpdateMetaData proc on my destination peer is always passed a value of NULL.

Can anyone shed light on this bizarre behavior? What I basically need to know is:

1. How are custom parameters passed values to the UpdateMetaData command/proc?  Funny thing is that I pass a value (in my app code) to a filter parameter to my SelectChanges proc on my Source peer and it is passed the value fine. If I pass a value for my UpdateMetaData parm on my destination peer in exactly the same way via app code, it consistently is passed NULL and seemingly ignore the value I set. Very wierd and highly confusing.

2. Are there any caveats or wierdness that is introduced to the sync process simply by having an IDENTITY field as a PK on the base table, requiring setting IDENTITY_INSERT on and off for inserts? This seems to be the only change in my app that breaks everything and I can't explain it.


Someone please help me understand how this works. It is *very* unintuitive and inconsistent to say the least.






I have a sample app that is a SQL Server peer-to-peer one-way sync app that seesm to be working fine except that when I insert a new record on the Souce Peer and sync, the record is not inserted on my Destination peer and I can't figure out why. I see a record appear in my tracking table that differs from the initially inserted records from the initial sync by:

scope_update_peer_key=0  , 1 for all other eecords





I am assuming the tombstone setting has something to do with it, but I can't figure out what. The code sample I am running is the SqlSyncProvider simple provider sample app. Does anyone know if this is how this is supposed to work and what I need to do to insure that any records added at my Source Peer and always added to my Destination peer on any successive syncs?


i have a windows xp peer to peer network in a small office environment and need a new computer. will a pc with windows 7 be able to join my XP machines on the network? Any other issues?

i want try to dev a silverlight video chat with peer to peer demo, but silverlight needs a 'SocketClientAccessPolicy' to connnect socket server,however the silverlight has not all the socket classes, like tcplistener, can a silverlight app play a server role and a client role  ? 



I've had Peer-to-peer Transactional Replication working great for the past few months.  Just this past week, I've encountered the following error:

Date  3/26/2008 10:35:40 AM
Log  Job History (SC1WV5431-LIMS-LIMS_Replication-MA1WV1302-11)

Step ID  2
Server  SC1WV5431
Job Name  SC1WV5431-LIMS-LIMS_Replication-MA1WV1302-11
Step Name  Run agent.
Duration  00:00:10
Sql Severity  0
Sql Message ID  0
Operator Emailed  
Operator Net sent  
Operator Paged  
Retries Attempted  0

2008-03-26 14:35:50.109 Category:COMMAND
Source:  Failed Command
Message: if @@trancount > 0 rollback tran
2008-03-26 14:35:50.109 Category:NULL
Source:  Microsoft SQL Native Client
Number:  20807
Message: No peers were found for SC1WV5431:LIMS:1. If you encounter this error when executing the stored procedure sp_requestpeerresponse, verify that subscriptions have been created before attempting to call the procedure again. If you encounter this error in other circumstances, contact Customer Support Services.
2008-03-26 14:35:50.109 Category:NULL
Source:  Microsoft SQL Native Client
Number:  21499
Message: The procedure sys.sp_MSupdatepeerlsn failed to UPDATE the resource MSpeer_lsns.. Server error = 0.

This is the error from the Agent Job.  The job from the other server runs perfectly with no errors.  I cannot find any help on this from Technet or google.

Has anyone encountered this before?


Jason Spangler




Are there any examples of the above in Windows Forms? I am quite familiar with the concept of peer to peer chat, and I already have a working example of peer to peer chat. How do I integrate audio/video from here? 

I also noticed there are more related examples in WPF, is it easier to do in WPF? How so?

But for now, are there any Windows Forms examples? I tried googling of course, but can't seem to find anything concrete. Yes, I have read about DirectShow.NET


how many node create in peer to peer transactional replication and it is possible in broadband connection .can we create  peer to peer transactional when database name is same in both server but table name is diffrent and table structure is same in both server.if 'yes'   then how.............

Iam developing Ip call based on UCC api. i abel to esatblish Audio\Video Call through SIP.

# Now i want to develop peer to peer call with out Register in SIP server.  give me suggestion how to do.

#i able to SetMediaPortRange , but how to set Listening TCP port .

pls give a solution or suggest any other way for solution.




HI there,

I am looking into implimenting a Peer to Peer solution in my application to broadcast certain events that happens in the application. Peer to peer looks like the way to be doing this. What I want to know is this:

If I implimen the WCF Peer to Peer, must all the applications that connect to this peer to peer service be a managed .Net application?

Can say a VB 6 application or a C++ application connect to my peer to peer service and still receive the events that I broadcast?

If not, how would I be going about to achieve that?



We have peer-to-peer replication set up on our system (2005 EE).

I would like to change the metadata of one of the tables (many of the tables actually, but right now I'm just trying to test out the process with just one table). As this is a high-availability system, I would like to stop the replication, make the changes on one node, verify that the changes are working, make the same changes on the other node, then re-enable replication. The ddl changes to the table are extensive enough that I have to clear them before executing. So I will handle re-populating the tables in a later step.

Right now I'm just testing the process of stopping, doing ddl, then restarting. I am trying to implement this using scripts so as to minimize my clicking (and thus potential for mistakes) when doing it for real.

I find that if I do the following process using the SSMS interface it goes smoothly with no errors (note that each step is conducted on both nodes unless specified):

stop sync agents manually remove article: tblName1 with 'publications properties window' close 'publications properties window' make ddl changes to tblName1 (change column names, add columns etc. to a particular table) manually add article: tblName1 with 'publications properties window' re-enable agents

But if I try the following, I get 'Peer-To-Peer topologies require identical articles in publications at all notes prior to synchronizing.' when the agents are re-enabled

stop sync agents drop the article from the subscriptions using sp_dropsubscription (script 1 below) drop the article from the publications using sp_droparticle and refresh subscription (script 2 below) make ddl changes add article using sp_addarticle  (script 3 below) re-enable agents

I suspect that there is something that 'publications properties window' calls or resets when I close it after dropping the article that I am not doing in my scripts. But I'm open to any ideas.

--Script 1:
DECLARE @publication AS SYSNAME ;
DECLARE @subscriber AS SYSNAME ;
DECLARE @destination_db AS SYSNAME ;
SET @publication = N'Main' ;
SET @article = N'tblName1' ;
 SET @subscriber = N'SvrNODE2'
ELSE SET @subscriber = N'SvrNODE1' ;
SET @destination_db = N'StageDB' ;

EXEC sys.sp_dropsubscription @publication = @publication, -- sysname
    @article = @article, -- sysname
    @subscriber = @subscriber, -- sysname
    @destination_db = @destination_db
Script 2:
DECLARE @publication AS sysname;
DECLARE @article AS sysname;
SET @publication = N'Main';
SET @article = N'tblName1';

-- Drop the transactional article.
EXEC sp_droparticle
  @publication = @publication,
  @article = @article,
  @force_invalidate_snapshot = 1;

-- refresh the subscriptions to remove the dropped articles.
EXEC sys.sp_refreshsubscriptions @publication = @publication, -- sysname
    @publisher = NULL -- sysname

Script 3:
DECLARE @publication AS sysname;
DECLARE @article AS sysname;
DECLARE @source_object AS sysname;
DECLARE @subscriber AS SYSNAME ;
DECLARE @destination_db AS SYSNAME ;

SET @publication = N'Main';
SET @article = N'tblName1';
SET @source_object = N'tblName1'
 SET @subscriber = N'SvrNODE2'
ELSE SET @subscriber = N'SvrNODE1' ;
SET @destination_db = N'StageDB' ;

-- add the transactional article.
EXEC sys.sp_addarticle @publication,
    @source_object, -- sysname
    @force_invalidate_snapshot = 1



I was wondering if anyone knew how or seen examples on how to create 2 WPF apps that connect via IP? I saw one example

however it only works over a LAN and not the internet.


Thank a lot everyone

Is there a way to make identity management work in peer-to-peer replication similar to the way it works in merge replication?

I do not want to be dependent on a central publisher, but I would rather not have to assign arbitrarily large starting identity values.


We setup a replciation peer-to-peer source / destination has sperated publisher and distributor each. 

The subscription set without initialize.  But the source db got changed before replication indeed.  Then we find there was something sent by destination distributor which hold all the process for a long time.

The question is: why is it not sent from source to destination? Does the destination try to question the change but very slow, and get the change back very quickly?


<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure