according to the agreement with Mr. Blake Robertson, i share the mail thread with him here. which contains detail discussion about the scenario Blake is now using tcpbridge service. also some common FAQs.
this mail achieve contains some information which has not been added into the readme.txt file in project.
Hides Blake's email address.

To: Blake Robertson
Subject: RE: TCP Bridge
Date: Mon, 18 Aug 2014 06:59:38 +0800

P.s. the functionality to change connecting timeout / retry interval, etc has been finished, the environment variables are,
tcp-watch-connectivity=15000 <15000 milliseconds, surely you can set to other value > 0, followings are the same>

There are still several other environment variables to control other TCP behavior, you can refer to /service/tcp/constants.vb.

From: 何子杰Hzj_jie
Sent: ?17/?8/?2014 11:11
To: Blake Robertson
Subject: RE: TCP Bridge

No problem, mail is also OK for me. :)

From: Blake Robertson
Sent: ?17/?8/?2014 4:11
To: 何子杰Hzj_jie
Subject: Re: TCP Bridge

No i do not mind. I will also use that discussion form for all future communications.

Thanks for the reply. Now the reset_parameter is clear.

Thanks again for the incredible support.

On Sat, Aug 16, 2014 at 8:01 AM, 何子杰Hzj_jie <> wrote:
Hi, Blake,
Thank you for your great feedbacks, and glad to know the software actually helps you. I will explain your questions and suggestions one by one.?
reset_connection, the default value is related to the response-timeout setting. So when it's true, the connection1 drops means connection2 will also be dropped.
Considering the following scenario, there is an http server, which serves more than one users concurrently. User A has sent 2 requests, the first one responded correctly, while for the second one, there are some temporary network issue, and the tcpbridge has time out. Since there are data transferred from both sides, and tcpbridge knows nothing about the application protocol. So though the bridge has been recycled, the connection from the tcpbridge to the http server has not been reset. Then user B has sent a request to the tcpbridge, the tcpbridge service has the chance to select the connection user A has just been using. And according to the TCP protocol, the response data for user A will be transferred to user B, which cause security issue.
Yes, the service leaks documentation. So would you mind if I post our mail thread to the codeplex project discussion or documentation page? And other users may be able to get useful information.
The service already has such functionality. You just need to set environment variable network_trace=1. There is a readme.txt in the project output folder, which has some information about the environment variables which can control the application behavior.
For the retry_connection parameter, I will also add it into environment variables. Which should be able to finish in several days.


From: Blake Robertson
Sent: ?Saturday?, ?August? ?16?, ?2014 ?2?:?49? ?AM
To: 何子杰

I really appreciate how responsive you are... Got it working and it kicks butt.
I noticed that it seems to drop connection1 when connection2 is lost even though the setting for this I

Here's some general feedback for helping your product get more traction.

I don't understand reset_connection, could you explain what you mean by "safe"

whether actively shutdown the connection even no error has been found during the transporting. since the transport is between two connections, one of them shutting down the connection does not mean we need to shutdown the other side. but this is not safe when the connection has been dropped instead of actively shutdown, and the data has not been fully transported to the destination. so if there is safety concern, it should be set to true.
not required, default value is false.

* Target - this was the missing piece for me. I didn't understand how it knew to connect each thing.
I would add that to your homepage. It was unclear to me when i read the homepage how things were connected. Also the default ini didn't show it on the first two connections which i suspect lazy people like me is all they look at :)

* I'd also include a link to the configuration page from the homepage. I find that most projects on codeplex and github don't ever have documentation so i didn't check it till later.

* Add more logging, i'd love to see what is happening. Like
* connected to "connection1",
* disconnected from "connection 2",
* got data from connection 1: X bytes
* connection 1 and connection 2 are connected

* Add a retry_connection param, I think the default is like 10 seconds or something. I'd like it to be faster.

On Thu, Aug 14, 2014 at 12:49 AM, 何子杰Hzj_jie <> wrote:
Yes, the TCP level keep alive is the key point, while there are still some logic to detect status according to windows socket behavior.
1. There are lots of small tools to run an application as windows service, try googling run as service, you will be able to get one, I believe.
2. The knowledge I am now having cannot support me to add TLS functionality in tcpbridge, but there are two simple symmetric-key encrypt algorithm which you can have a try.
3. Yes, the token can be used to decide which group the connection belongs to, and also as the key for encryption.
4. This is a breaking change to existing logic, I am afraid this requirement means almost the whole streamer component <you may find an osi.service.streamer.dll, which is the component to handle bridge generation, recycle, and data transfer.> needs to be changed.

From: Blake Robertson
Sent: ?14/?8/?2014 3:00

To: 何子杰Hzj_jie
Subject: Re: TCP Bridge

Interesting. How much do you charge for development?

Might want:
- Service Wrapper (run as windows service)
- Ability to support TLS on one connection
- Upon connection to remote, have it send a packet "Organization: <ID>" perhaps your token sending could be used for this...
- Buffering of data from one connection and send once remote connection becomes available

What is still unclear to me is how you monitor the connections without some additional application code...
Unless it's using TCP Keep Alive or something... a socket can be lost on the other end without closing the connection so the bridge might not know it's gone.

On Wed, Aug 13, 2014 at 2:22 PM, 何子杰Hzj_jie <> wrote:
There are several constants to control the connection poll and reconnecting,
The connector, which is the component taking responsibility to generate outgoing connections, will check whether the connection count meets the expectation per 100ms. But if last connection generation attempt has failed, i.e. dns resolve error, or connection refused by the other side, connector will wait for 1 second before retrying.
The closer, which is the component taking responsibility to detect whether a connection has been dropped by the other side, will poll the connection status per 15 seconds.
Briefly the dead connection will be able to be detected and replaced by a new connection in not more then 15.1 seconds, the average latency should be 7.55 seconds. <do not count the time to generate a new connection, it highly depends on network status, and also do not count the processor time, which should be in millisecond scale>.

The connections are aggregated and managed by groups, which means the connections coming from or targeting to a same remote ip should have same meaning. I.e. no matter how many connections a browser has been generated to a certain http server, each of the connections should be able to serve the html content or css file without any difference.
So when tcpbridge is configured to bridge data between two connection groups, if any data from one group has come, tcpbridge service will choose a random connection from the other group and generate the bridge. The following data will be transferred on the bridge. The bridge will be recycled only when timeout or one side has shutdown the connection.
In your scenario, if you only need one connection, you can set max_connected to 1.


From: Blake Robertson
Sent: ?Thursday?, ?August? ?14?, ?2014 ?1?:?07? ?AM
To: 何子杰

Yeah, i suspected that might be it...

So, how often does it try to reconnect if the connection is lost?
And this is all i would have in my config right for two outbound connections?

I guess what really confuses me in the documentation is when there are more then two connections... like how does it know who to connect each to.

Thanks a million for your help!



On Wed, Aug 13, 2014 at 12:59 PM, 何子杰Hzj_jie <> wrote:
Yea, the connections are automatically generated and the service can detect dropped connections.
The error you have seen looks like you do not have .net 3.5 installed.

From: Blake Robertson
Sent: ?14/?8/?2014 0:14
To: 何子杰Hzj_jie
Subject: Re: TCP Bridge

Hey Hzj,

Thanks for the reply and permission.

So, does it already handle reconnecting of sockets? I got the following error when i tried to use your service.


Unhandled Exception: System.TypeInitializationException: The type initializer fo
r 'osi.production.tcp_bridge.tcp_bridge' threw an exception. ---> System.TypeIni
tializationException: The type initializer for 'osi.root.utils._domain_unhandled
_exception' threw an exception. ---> System.TypeInitializationException: The typ
e initializer for 'osi.root.utils.application_lifetime._application_lifetime' th
rew an exception. ---> System.TypeInitializationException: The type initializer
for 'osi.root.utils.application_lifetime_binder`1' threw an exception. ---> Syst
em.TypeInitializationException: The type initializer for 'osi.root.utils.object_
unique_set`2' threw an exception. ---> System.IO.FileNotFoundException: Could no
t load file or assembly 'System.Core, Version=, Culture=neutral, PublicKe
yToken=b77a5c561934e089' or one of its dependencies. The system cannot find the
file specified.
File name: 'System.Core, Version=, Culture=neutral, PublicKeyToken=b77a5c
at osi.root.connector._alloc.alloc_cache`1.allocate()
at osi.root.connector._alloc.alloc[valueT]() in C:\Users\zijiehe\Documents\Vi
sual Studio 2012\Projects\tcpbridge\root\connector\alloc.vb:line 207
at osi.root.utils.object_unique_set`2..cctor() in C:\Users\zijiehe\Documents\
Visual Studio 2012\Projects\tcpbridge\root\utils\formation\threadsafe\object_uni
que_set.vb:line 19

On Wed, Aug 13, 2014 at 6:00 AM, 何子杰Hzj_jie <> wrote:
Hi, Blake, the scenario you have mentioned is the typical user scenario of tcpbridge, and the initial purpose of the service. Currently tcpbridge can help to maintain connections, transfer data between connections, and a not released version in can compress and encrypt data transferred between two tcpbridge services.

It's OK for you and your org to use the software freely, but please pay attention, as a free and open source software, I hope it will be useful, but without any warranty. I.e. I do not commit its usability. :)
Only two simple requirements to protect my right,
1. As the author of the software, this mail does not contain any implication to allow any one to sell the software or part of the source code without further agreement with me.
2. You need to present to others, the components or systems using this software are powered by Hzj_jie's tcpbridge service.

From: Blake Robertson
Sent: ?13/?8/?2014 16:35
Subject: TCP Bridge


Might be interested in using tcp bridge commercially.

I need something that will allow me to connect to two services.

On Premise Server --> Socket A (a localhost service)
--> Socket B (a remote internet service)

Both connections are initiated by computer that would run tcp-bridge.
Then, any data received on socket A would get written to socket B and vice versa.

I'd need it to run as a service.

I wrote a simple bridge that already does that. What I need is something more robust such that if Socket B dies... tcp bridge will try and reconnect every 5 seconds. Ideally, it'd even buffer all the data socket A produced and then send it when it reconnected... but this is not essential.

I don't have a big budget... But, thought i'd reach out in case you wanted to leverage your codebase. Please let me know.

Blake Robertson
Blake Robertson

Blake Robertson
Blake Robertson

Blake Robertson
Blake Robertson

Blake Robertson
Blake Robertson

Blake Robertson
Blake Robertson

Blake Robertson
Blake Robertson

Last edited Aug 18, 2014 at 8:51 AM by Hzj_jie, version 1


No comments yet.