Question

Imagine situation (this is real situation):

There is a WCF client application on laptop. Laptop is connected by WiFi to internet. User is doing some stuff (request reply operations) on his laptop at work connected to WCF service.

Then user's laptop is sleep-down and user go home. At home user wake-up his laptop, connect HSPDA/3G modem (different interface & ip) and want to continue on work in client appliaction. Note that application hasn't been closed.

User (client application) should be authenticated and if it is possible, communication should be encrypted.

What are the best practices? Create new proxy for each operation? This should be very slow when initializing net.tcp connection with authentication.

Is solution basicHttp connection (+HTTPS) with InstanceContextMode.PerCall? Note that speed and higher payload is problem.

Or the best solution is something like "wrapper(Func<>)", which contains while loop until operation is successfully finished (on fail, new connection is created and function is called again).

Thanks you for suggestions

Was it helpful?

Solution

I've always kept the connection open for as long as the unit of work is necessary. Basically, the connection is only open and available while the application is performing some processing (and those processes require a WCF connection). It may be more overhead to keep reconnecting (and depending on connection speed it may add latency) but it's also more secure when it comes to having a connection to work with (least probability of failure) and I'm generally saving those resources for other purposes.

However, this all depends on what the application does; If the client is dumb and the service is doing all the work it may make sense to keep the connection as every function executes a method on the service. Though with that comes some failure checking and re-establishing should the connection be unexpectedly severed.

Also, netTcp is going to be a lot faster than wsHttp. And I personally haven't see a lot of latency on establishing a netTcp connection (though I don't know what kind of authentication you're doing [mine has generally implemented windows authentication])

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top