wodVPN For 1 Server - N Client Scenario - WeOnlyDo Discussion board

wodVPN For 1 Server - N Client Scenario (wodVPN)

by Tanmay, Friday, October 10, 2008, 17:54 (5886 days ago)

Hello,
We have wodVPN component [v2.0.1 July 20, 2008], to achieve our SIMPLE (!!) requirement, which we are not able to get through. As it's becoming much urgent, we would like to get specific and timely response, which we have observed, to occur, at support forum.

Our requirement is as below [which should be very familiar]:
1. A dedicated server, which would run Mediator [script or application, doesn't matter at this stage].
2. A LAN Server, which would act as application and DB server to our enterprise application; this server MUST provide a mean for N-Clients to connect to it using wodVPN.
3. A client application, that would connect to server [by looking up at mediator].

The key concern here is, implementation of wodVPN at server side, to enable multiple connections at any given point of time.

Per our interpretation of wodVPN behavior, we expected to achieve this by doing following AT SERVER SIDE:
1. Create wodVPN instance.
2. Call wodVPN.Start for port 'p'.
3. Whenever a client would need to connect, it would send SEARCH request to mediator; mediator would respond with server's IP and port 'p'; and then, client invokes CONNECT to server with given IP and port.
4. When CONNECTING event fires at server, respond to the request to accept the connection [after some business checks] which causes CONNECTED event to fire.
5. At CONNECTED event, create a NEW CHANNEL, for this client and ensure all NOW-ON communication for THIS client, occurs through THIS NEW CHANNEL only.
6. This leaves our original port 'P' FREE FOR NEW CLIENT requests.

Having this interpretation, we tried a lot to achieve 5 and 6, but NO SUCCESS. The result was, once any one client connected to server on port 'p', even after creating a new channel with ANOTHER port of server, with that client, the server DID NOT ACCEPT connections from any other client.

After a while, we received new version of SDK that used virtual adapter; and we came to know it automatically handles this; but still we do NOT find this to occur.


This makes wodVPN usage in question, if it misses such basic thing OR guidance to achieve such basic thing/objective. Still, we are inclined to believe that we might be missing something, due to lack of clear documentation [real classes have certain +/- then pdf!!].

We would like to know the SPECIFIC STEPS, at SERVER and CLIENT side [for our above requirement] that we should implement with wodVPN, to achieve our objectives 1 to 6 above.

Additionally, it would help us greatly if we get answers on some of our fundamental questions, to clarify our doubts:

1. Given that we are using Adapter based wodVPN, is it MUST to have MORE THEN ONE instance of wodVPN, to support N-clients [or incoming connections] OR is it possible through SINGLE wodVPN instance?

2. Given that we are using Adapter based wodVPN, does channel and port forwarding concepts have any significance now? better, what is the impact on channel and port-forwarding concepts, by inclusion of Adapter in wodVPN?

A thorough and timely response would be MUCH MUCH appreciated.

Re: wodVPN For 1 Server - N Client Scenario

by wodDamir, Friday, October 10, 2008, 21:02 (5886 days ago) @ Tanmay

Tanmay,

Did you set Threads property to true? If not, please try it too.

Also, in order to accept multiple connections, you should do something like this:

[code] VpnServer1.Mediator.Timeout = 15;
VpnServer1.Threads = true;
VpnServer1.MediatorConnected += new WODVPNCOMLib._IwodVPNComEvents_MediatorConnectedEventHandler(VpnServer1_MediatorConnected);

VpnServer1.Mediator.Start(WODVPNCOMLib.SearchEnum.SrchUDPSingle,8000);[/code]

As you can see from the above code, we would use MediatorConnected to detect incoming connection. We do that in order to initiate new wodVPN instance, which will do search (for the incoming peer's ID)and establish connection to it once found.

I've tried the above, and I was able to connect two peers to server instance of wodVPN.

However, please note that wodVPN is peer-2-peer component. There is no Server-client approach available. Server in this case can only be many instances of wodVPN.

Also, in Adapter based wodVPN you still will need multiple component instances for the above mentioned reason. Each wodVPN component can connect only two peers. You need new instances to connect more peers.

As for your last question, when you use Adapter, *all* traffic is redirected between peers, while when using channels, only certain traffic is redirected.

Regards,
Damba

Re: wodVPN For 1 Server - N Client Scenario

by tanmay, Saturday, October 11, 2008, 15:48 (5885 days ago) @ wodDamir

Hello Damba,
Thanks for your response.

Firstly, below are my comments for each of your point.

Did you set Threads property to true? If not, please try it too.

Yes. It does not make difference for our purpose at hand.


Also, in order to accept multiple connections, you should do something like this:

Code: VpnServer1.Mediator.Timeout = 15;
VpnServer1.Threads = true;
VpnServer1.MediatorConnected += new WODVPNCOMLib._IwodVPNComEvents_MediatorConnectedEventHandler(VpnServer1_MediatorConnected);

VpnServer1.Mediator.Start(WODVPNCOMLib.SearchEnum.SrchUDPSingle,8000);


As you can see from the above code, we would use MediatorConnected to detect incoming connection. We do that in order to initiate new wodVPN instance, which will do search (for the incoming peer's ID)and establish connection to it once found.

I've tried the above, and I was able to connect two peers to server instance of wodVPN.

I would like to confirm - do you mean to have the above code AT MEDIATOR ? [as mediator connected event is fired at mediator only].
Please advise, where should this code be placed.


However, please note that wodVPN is peer-2-peer component. There is no Server-client approach available. Server in this case can only be many instances of wodVPN.

Also, in Adapter based wodVPN you still will need multiple component instances for the above mentioned reason. Each wodVPN component can connect only two peers. You need new instances to connect more peers.
OK. We now believe that MULTIPLE-WODVPN INSTANCES ARE ONLY WAY to have multiple connectivity at a given time.
Given this, we would like to know, how does wodVPN support ability to have multiple simultaneous connections at given peer, WITH SAME ID [the MyID value]? We don't find support for establishing multiple SIMULTANEOUS connections to given peer, with ability to locate it through SAME ID. Please advise, as this is VERY CRUCIAL for us.


As for your last question, when you use Adapter, *all* traffic is redirected between peers, while when using channels, only certain traffic is redirected.

Unfortunately, we don't understand this statement completely, since it does not specify details about which traffic is NOT redirected. But that may not be our concern at least at this point when we don't get our most basic requirements - simultaneous multiple connections to a peer with same id.

We would like to know your answers to below:

We have tried name-fooling at mediator [php script], to enable consequent client search requests, to get the response for same server [although at different port]. And we have got the mediator to return the result to searching client. In spite of this, the client is not able to connect to the server. Can you please give us details on EXACT STEPS followed by searching peer, after receiving successful search result from mediator, to connect to the resultant peer.?

Hoping to hear from you soon.

Re: wodVPN For 1 Server - N Client Scenario

by wodDamir, Saturday, October 11, 2008, 17:53 (5885 days ago) @ tanmay

Hi Tanmay,

Let me try to explain. You can find a sample code below which should demonstrate the way I accomplished this. I use 3 wodVPN instances to connect two users (3rd is Mediator, which is used to detect incoming connection).

Also, I declared all of the instances statically, but I believe it should be sufficient for this sample to show howo i imagined this.

EDIT: Since whole code doesn't fit here, I'll post it in second one.

I would like to confirm - do you mean to have the above code AT MEDIATOR ? [as mediator connected event is fired at mediator only]. Please advise, where should this code be placed.

Yes, as seen from the sample code.

Given this, we would like to know, how does wodVPN support ability to have multiple simultaneous connections at given peer, WITH SAME ID [the MyID value]?

Both instances that connect to clients have the same MyID property, so I don't see a reason for this not to work.

Hope this helps.

Regards,
Damba

Re: wodVPN For 1 Server - N Client Scenario

by wodDamir, Saturday, October 11, 2008, 17:58 (5885 days ago) @ wodDamir

[code]namespace WindowsApplication4
{
public partial class Form1 : Form
{
//This is where i made declarations
private WODVPNCOMLib.wodVPNComClass VpnServer1;
private WODVPNCOMLib.wodVPNComClass VpnClient1, VpnClient2;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
//Initialize components
VpnServer1 = new WODVPNCOMLib.wodVPNComClass();
VpnClient1 = new WODVPNCOMLib.wodVPNComClass();
VpnClient2 = new WODVPNCOMLib.wodVPNComClass();

//assign settings, and start listening
VpnClient1 = new WODVPNCOMLib.wodVPNComClass();
VpnClient1.Connected += new WODVPNCOMLib._IwodVPNComEvents_ConnectedEventHandler

(VpnClient1_Connected);
VpnClient1.SearchDone += new WODVPNCOMLib._IwodVPNComEvents_SearchDoneEventHandler

(VpnClient1_SearchDone);
VpnClient1.MyID = Server ;
VpnClient1.Password = anypass... ;
VpnClient1.Timeout = 15;
VpnClient1.Start(0);

VpnClient2 = new WODVPNCOMLib.wodVPNComClass();
VpnClient2.Connected += new WODVPNCOMLib._IwodVPNComEvents_ConnectedEventHandler

(VpnClient2_Connected);
VpnClient2.SearchDone += new WODVPNCOMLib._IwodVPNComEvents_SearchDoneEventHandler

(VpnClient2_SearchDone);
VpnClient2.MyID = Server ;
VpnClient2.Password = anypass... ;
VpnClient2.Timeout = 15;
VpnClient2.Start(0);

//Start mediator
VpnServer1.Mediator.Timeout = 1;
VpnServer1.Threads = true;
VpnServer1.MediatorConnected += new WODVPNCOMLib._IwodVPNComEvents_MediatorConnectedEventHandler

(VpnServer1_MediatorConnected);
VpnServer1.Mediator.Start(WODVPNCOMLib.SearchEnum.SrchUDPSingle,8000);
}
//When search is done, connect...
void VpnClient1_SearchDone(string IP, int Port, int ErrorCode, string ErrorText)
{
if (ErrorCode == 0)
{
VpnClient1.Connect(IP, Port);

}
else
{
Console.WriteLine(ErrorText);
}
}

void VpnClient2_SearchDone(string IP, int Port, int ErrorCode, string ErrorText)
{
if (ErrorCode == 0){
VpnClient2.Connect(IP, Port);}
else{
Console.WriteLine(ErrorText);}
}

//This part is where we detect the user connection, and decide which instance to use in order to connect peers
void VpnServer1_MediatorConnected(string IP, int Port, string FromID, string ToID, string Data, ref bool Allow)
{
try
{if (VpnClient1.State == WODVPNCOMLib.StatesEnum.Listening)
{
VpnClient1.Search(WODVPNCOMLib.SearchEnum.SrchUDPSingle, FromID, 127.0.0.1 , 8000, null);
}
else if (VpnClient1.State == WODVPNCOMLib.StatesEnum.Connected && VpnClient2.State == WODVPNCOMLib.StatesEnum.Listening)
{
VpnClient2.Search(WODVPNCOMLib.SearchEnum.SrchUDPSingle, FromID, 127.0.0.1 , 8000, null);
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
}
//Just log the connection
void VpnClient1_Connected(string PeerID, string IP, int Port)
{
Console.WriteLine( Client1 connected with + PeerID + on + IP);
}

void VpnClient2_Connected(string PeerID, string IP, int Port)
{
Console.WriteLine( Client2 connected with + PeerID + on + IP);
}
}
}
[/code]

Re: wodVPN For 1 Server - N Client Scenario

by Tanmay Soni, Monday, October 13, 2008, 08:50 (5884 days ago) @ wodDamir

Hello,
Thanks for response.

In given code sample in Mediator_connected event , you have called the search method for client...but as per our requirement we are having mediator service on another mc.. so how can we get the wod client object over there and call the search method for it.

Please let us know your comments for above.

Regards,
Tanmay Soni.

Re: wodVPN For 1 Server - N Client Scenario

by wodDamir, Monday, October 13, 2008, 11:22 (5884 days ago) @ Tanmay Soni

Hi Soni,

You can't get instance of wodVPN there, however, in that case you should use Connected event to start new instance of wodVPN which will accept new connection.

In this case, clients will be names same. Also, you should lower the Timeout property in Mediator (determines how long it takes before mediator will ignore the last request), and set client instances to Retry (RetryWait and RetryCount properties) if no connection is established.

Hope this helps.

Regards,
Damba