I'm currently building a game that uses a client/server model. I'd like the server side to be a WCF service. The client will be silverlight or flash. What need to solve is session authentication. A user needs to log into the game, be authenticated via the service and hopefully establish a "session." I need to make sure that you can't send commands to the server without being authenticated. Authentication on the server side will be tied to a SQL database. I should also mention that it needs to be a duplex connection.
Related to this question, what about load balancing? If the service runs on multiple machines and is load balanced with the NLB service and I store those connection references, how would I get a reference to a client connected to a different machine in the same cluster?
Related
UPDATE 2: Solved the first problem (note below) - reduced the complexity/scope.
NOTE: If migrating from self-hosting WCF services in Cloud Services to Service Fabric using HttpsBinding then you need to change the HostNameComparisonMode from Exact to StrongWildcard.
I have scenario where I have to open many (100+) WCF Service Hosts to receive callbacks from an external service. They have same Contract but with differing credentials (service certificates are unique to each of our customers).
I would like to know if it is possible to route all requests through a single Host/Router that could check the connecting clients expected service certificate and either a) spoof/ignore (preferably) the service certificate or forward the connection onto the correct host.
I want to avoid having to load hundreds of service hosts with different credentials (which are stored in a database) when the service fabric node first comes up so I don't receive traffic to a service that's not loaded yet. Ideally I could load them when needed or not have to load them at all (spoofing certificate or something).
Looking for someone who is a lot savvier with WCF to shed some light on the possibilities. Thanks.
I need to build a server and a client that can exchange data in real time with a company's proxy between them. No one has the authorisation to amend the proxy's configuration (in order to allow the WebSocket protocol).
I would need a fallback technology such as long-polling.
Example: client is a user's PC employee. He needs to exchange data with the server, located in the cloud and separated by company's proxy.
Ideally, I would use WebSocket with SSL, but I know some proxies are not configured for WebSocket messages and thus could reject the connection.
The app would therefore switch to another push technology such as long-polling, increasing the chances of getting a successful connection (is 100% guaranteed with proxies? Giving that there are several types of proxies...)
Are there any libraries/frameworks proposing such features?
Usually, secure WebSocket connections do fine through proxies.
In .NET you have SignalR
In node.js you have socket.io
I have many clients connected to a server in SignalR
but I want the server to redirect or route all of the Requests to another server , and to route the response to the clients in the same way used in WCF routing service so how can we do this on SignalR ,please ?
To be more specific
I have a server with a web app published on internet
some of the clients Devices cannot connect to the internet
I need to connect them to the server via an intermediate machine connected to the internet.
The client can connect to this machine and the machine connect to the internet then to the main server.
I used WCF routing services to do it for WCF
but what is the technique for SignalR ?
thanks
You can make each of your SignalR machines individually addressable and then have a single machine manage which clients should connect to which SignalR servers.
Each client could make an Ajax request to the management machine which could then respond with the URL the client should establish a SignalR connection to.
If you need clients on separate machines to be able to communicate with each other using SignalR, you should look into SignalR's scaleout providers: http://www.asp.net/signalr/overview/signalr-20/performance-and-scaling/scaleout-in-signalr
As indicated by the first diagram in the previous link, you can put your SignalR servers behind a dumb load balancer if you decide to use a scaleout backplane.
What Works
I built a DataSnap web service in Delphi-XE2, which uses the TDSServer and TDSHTTPService components. Clients attach to the server (web service) and run DataSnap server methods to retrieve data. The server uses TDSLifeCycle.Session for all connections. I want to continue to use Session if possible because I store session information in thread variables...
I can use Internet Explorer to authenticate to and retrieve data from the DataSnap server. If I don't let IE sit idle for 30 seconds (or it disconnects from the server), it will reuse the same connection for every method request.
I can use a simple Delphi app that uses TIdHTTP to connect to the DataSnap server. Adding keep-alive to its Request.Connection property makes it stay connected forever and reuse the one connection for all method calls.
.
Problem
A 3rd party company is building a WCF app to access the DataSnap service. They can't get WCF app to use only one connection to the service. The initial authentication request and 1st method call use the same connection, but subsequent requests create new connections, evident by running netstat on their computer and seeing new ESTABLISHED connections from their app to my service using multiple source ports. New connections create new threads in the DataSnap server, which can't access the authenticated thread's session variables.
.
Possible Workaround
I know that I can change the DataSnap server to an Invocation model, making it unnecessary to maintain one persistent connection per client, and will do this if needed. Before doing so, I thought it prudent to see if anyone else knows how solve the problem.
.
My Question
Is it possible for a WCF client app to create a single persistent connection to a non-WCF server (DataSnap server) that it uses for all method calls without it creating new connections? How is this done? Is it as simple as adding the right [decoration] to the C# WCF project in Visual Studio?
Any suggestions are greatly appreciated!
.
FYI - I don't have access to the 3rd party's code, so I can't provide samples of the WCF code.
Your Delphi application provides a stateful web service (using session variables), and WCF web services are stateless by default, including WCF clients.
Maybe this answer points to the correct configuration (wsHttpBinding and SessionMode of the ServiceContract).
From the MSDN ocumentation:
For example, if the SessionMode property is set to
SessionMode.Required and the InstanceContextMode property is set to
PerSession, clients can use the same connection to make repeated calls
to the same service object.
(highlighting by me)
However, as DataSnap is not primarily designed for interoperability with WCF it might be easier to re-design the Delphi side to use a stateless web service model instead of stateful. This would require authentication with every service request, but internally the Delphi web service could some cache data to reduce lookup times, similar to the current session state.
Here is my scenario, and it is causing us a considerable amount of grief at the moment:
We have a vendor web service which provides base level telephony functionality. This service has a SOAP api, which we are leveraging to build up a custom UI that is integrated into our in house web apps. The api functions on 2 levels. You make standard client calls into the service to initiate actions, such as Login, Place Call, Hang Up, etc. On a different thread, the service sends events back to the client to alert the user of things that are occurring on the system (agent successfully logged in, call was disconnected, etc).
I implemented a WCF service to sit between the web server and the vendor service. This WCF service operates in duplex mode, establishing a 2 way connection with the web server. The web server makes outbound calls to the WCF service, which routes them to the vendor's web service. Events are received back to the WCF service, which passes them onto the web server via a callback channel on the WCF client. As events are received on the web server, they are placed into a hash table with the user's name as the key, and a .NET queue as the value to hold the event. Each event is enqueued to the agent who owns it.
On a 2 second interval, the web page polls the web server via an ajax request to get new events for the logged in user. It hits the hash table for the user key, dequeues any events that are present, and serializes them back up to the web page. From there, they are processed in order and appropriate messages are displayed to the user.
This implementation performs well in a single user scenario. The second I put more than 1 user on the system, I start getting frequent timeouts with the following CommunicationException:
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
We are running Windows Server 2008 R2 both servers. Both the web app and WCF service are running on .NET 3.5. The WCF service is running under the net.tcp protocol in duplex mode. The web app is ASP.NET MVC 2.
Has anyone dealt with anything like this scenario? Is there a more efficient way (or a widely accepted pattern) to implement this?
EDIT: One thing I forgot to mention - my thought is that the increased traffic (adding additional users) with only 1 dedicated callback channel is causing locking, which then triggers the timeout. There can be up to 10 consecutive callbacks from the service within any 5 second interval.