|
.NET Remoting is a very cool technology to build programs communicating each other over the WAN, LAN or single computer. It is supplied with a number of network transports and protocols support. But there are several common issues that almost everybody will have to solve to make applications more robust and reliable.
We found .NET Remoting is very useful and able to speedup application development. But during intensive testing process we also found this:
Imagine that you made a call to the method exposed by the server's type. How long should you wait for the response? This is really hard to answer question in general. Some methods need seconds to complete, others require hours. By default in .NET Remoting if you make a call then client will wait result infinite amount of time. Ok. That's good. But the problem is withing not stable nature of network connections. Imagine that client made a call, then server worked for 5 seconds and was ready to return the result of the call to the client, but at this moment connection between the server and client became unavailable. What are the consequences? Server got an exception and discovered network error - good. But the client is still waiting. And it leads us to the situation, when the client will wait forever and will never know that there was a network error.
You may try to solve the issue arranging polling of the server in the background thread. And this will not solve the issue, becouse network may be down when server tries to reply to the client, but it may be up again when you poll the server.
Here our SmartChannels library comes. The main goal we created this library is to be able to detect network failures on the sink level transparently for the applications. Applications do not need to worry about polling and reliability of network failures detection. They get it with SmartChannels library and couple of strings inside app.config. The library contains 2 sink providers for that: TosChannelSinkProvider (server-side provider) and TocChannelSinkProvider (client-side provider)
In case your client calls a server and network failure is detected, your client will receive an exception RemotingTimeoutException.
Another feature that we later added to the library is an ability to authorize clients using simple pre-shared key approach. Working with globally distributed networks we found that it is not always possible to use windows authentication and authorization between clients and server (clients and server may belong to different domains without trusts e.t.c). But there is still a need to restrict somehow connections to the server and allow only particular clients to use the server's functionality. That's why we have added to the library two sink providers that supports pre-shared key authorization: AzsChannelSinkProvider (server-side provider) and AzcChannelSinkProvider (client-side provider).
This are the brief SmartChannels library sink providers classes details:
|
TocChannelSinkProvider
|
Client-side provider with support of network failures and client/server disconnection detection
|
|
|
|
|
Supported properties:
|
|
|
defaultPollingInterval
|
Default amount of time in seconds which determines how often client will send system requests to the server in order to detect network failures, client or server disconnections and network timeouts If explicit polling interval is not set for the destination, then default will be used.
|
|
defaultTimeoutInterval
|
Default amount of time in seconds which determines how long client will wait the response on service request from the server before treating network connection as timed out. If explicit timeout interval is not set for the destination, then default will be uses.
|
|
Supported data entries:
|
|
|
destination
|
Allows to set properties per destination
|
|
Destination data entry properties:
|
|
|
url
|
URL that defines the destination
|
|
pollingInterval
|
Amount of time in seconds which determines how often client will send system requests to the server at destination in order to detect network failures, client or server disconnections and network timeouts.
|
|
timeoutInterval
|
Amount of time in seconds which determines how long client will wait the response on service request from the server at destination before treating network connection as timed out.
|
|
Example of configuration:
|
|
<clientProviders>
<formatter ref="binary"/>
<provider type="SSB.Runtime.Remoting.TocChannelSinkProvider, SmartChannels" defaultPollingInterval="30" defaultTimeoutInterval="10" >
<destination url="tcp://SERVER1.COM:5000/MyService.rem" pollingInterval="20" timeoutInterval="40" />
<destination url="tcp://SERVER2.COM:5050/AnotherService.rem" pollingInterval="10" timeoutInterval="5" />
</provider>
</clientProviders>
|
|
TosChannelSinkProvider
|
Server-side provider with support of network failures and client/server disconnection detection.
|
|
|
|
|
Configuration properties:
|
None
|
|
|
|
|
Example of configuration:
|
|
<serverProviders>
<provider type=”SSB.Runtime.Remoting.TosChannelSinkProvider, SmartChannels” />
<formatter ref=”binary” />
</serverProviders>
|
|
AzcChannelsSinkProvider
|
Client-side provider with support of pre-shared key authorization as well as network failures and client/server disconnection detection
|
|
|
|
|
Supported properties:
|
|
|
defaultServerKey
|
Encoded default server key (password). If explicit server key is not set for the destination, then default will be used. Decoded key on server side should match this decoded key.
|
|
defaultNumRetries
|
Default number of retries to deliver message over the network. Improves workability in non stable networks. If explicit number is not set for the destination, then this default value will be used.
|
|
defaultPollingInterval
|
Default amount of time in seconds which determines how often client will send system requests to the server in order to detect network failures, client or server disconnections and network timeouts If explicit polling interval is not set for the destination, then default will be used.
|
|
defaultTimeoutInterval
|
Default amount of time in seconds which determines how long client will wait the response on service request from the server before treating network connection as timed out. If explicit timeout interval is not set for the destination, then default will be uses.
|
|
Supported data entries:
|
|
|
destination
|
Allows to set properties per destination
|
|
Destination data entry properties:
|
|
|
url
|
URL that defines the destination
|
|
serverKey
|
Encoded server key (password) for the destination. Decoded key at the destination side should match this decoded key.
|
|
numRetries
|
Number of retries to deliver message over the network. Improves workability in non stable networks.
|
|
pollingInterval
|
Amount of time in seconds which determines how often client will send system requests to the server at destination in order to detect network failures, client or server disconnections and network timeouts.
|
|
timeoutInterval
|
Amount of time in seconds which determines how long client will wait the response on service request from the server at destination before treating network connection as timed out.
|
|
Example of configuration:
|
|
<clientProviders>
<formatter ref="binary"/>
<provider type="SSB.Runtime.Remoting.AzcChannelSinkProvider, SmartChannels" defaultPollingInterval="10" defaultTimeoutInterval="5" defaultServerKey="smF87+vjbrC9hw51Ud4lsA==" >
<destination url="tcp://SERVER1.COM:5000/MyService.rem" pollingInterval="5" timeoutInterval="2" serverKey="HUanOCyMuZKguUL703ztMg==" />
<destination url="tcp://SERVER2.COM:5050/AnotherService.rem" pollingInterval="40" timeoutInterval="20" serverKey="fXnZf0JozwhY/YK0gv84EA==" numRetries="3" />
</provider>
</clientProviders>
|
|
AzsChannelSinkProvider
|
Server-side provider with support of pre-shared key authorization as well as network failures and client/server disconnection detection
|
|
|
|
|
Supported properties:
|
|
|
serverKey
|
Encoded server key. Clients should know it in order to connect successfully.
|
|
connectionAgeLimit
|
Amount of time in seconds since last client request before treating client's authorization expired. (Performance fine-tuning)
|
|
sweepFrequency
|
Interval in seconds between connection sweeper run. (Performance fine-tuning)
|
|
Example of configuration:
|
|
<serverProviders>
<provider type="SSB.Runtime.Remoting.AzsChannelSinkProvider, SmartChannels" serverKey="Xd8ithdJ7R8d3AKTl104eQ==" />
<formatter ref="binary" />
</serverProviders>
|
Therefore, SmartChannels is a small but useful .NET assembly delivering four .NET Remoting channel sink providers that you may embeed in standard .NET Remoting channels using standard configuration files or programmatically. This providers give you solution for client/server disconnection and network timeouts detection along with simple pre-share key authorization.
|