I have looked all over the place and have never seen an example of how to do this, even tho it's alluded to in blogs. But examples are never given.
I have a .Net remoting client that is connected to a server which is published as a well known type over tcp/ip. It holds an object reference to the server and instantiates it via the new operator.
If the server crashes, the easy part is detecting this, just catch the error.
Looping and waiting for the server to come back up will again be no problem.
But how to reset / reboot / unregister then re-register the remoting stack on the client?!?
If the client is restarted after the server comes back up, it works again, but obviously I want to just reconnect within the client application and not have to reboot it.
Windows Communication Foundation does not have the same issue. When the server goes down, the connection can be programatically re-established.
Related
I would like to add some conditional logic to our Java application code for attempting to create a JMS Topic Connection. I have seen problems in the past stemming from attempting to create a connection when the MQ server had been restarted or was currently down. One improvement I added was to check for the quiescent state, and another was to increase the timer before attempting reconnection to our durable topic queue.
Is there a way to confirm with the MQ server/topic/channel that it is up and running and a connection request can safely be made?
The best way to confirm that a queue manager (and the channel you are using to connect to the queue manager) is up and running is to attempt to connect to it.
If your connection attempt fails, you will get an MQ Reason code telling you exactly why. This is a much better way to confirm than any administrative command, because it also confirms that your application, and it's security context is correct and able to connect to the queue manager. It is completely possible to have an up-and-running queue manager but an application that is not yet correctly configured to use it. So connect from the application and if it works, the queue manager is up-and-running.
Your comment about having an increased timer before attempting to reconnect after a failure is well made. It doesn't help anyone if you hammer the queue manager with lots of repeated and close together connection attempts until it is ready to accept your connection, but still anything that is going to test the availability of the queue manager needs to ultimately connect to it, so very simply, just connect.
I have two desktop apps on the same machine, let's call them Client and Server. When Windows goes into shutdown I would like to have the Client do some short housecleaning with the Server. Client knows it's closing time because in OnFormClosing the FormClosingEventArgs.CloseReason is CloseReason.WindowsShutDown. But in the mean time the Server may be forcefully killed by the OS. Is it possible to have the Server alive for as long as possible, so that all the Clients can finish their jobs, but not halt the shutdown entirely?
The Server does not know which Clients are alive and in need of housecleaning.
Both Client and Server should not cause the Windows to show the message saying that the app is preventing the Windows from shutting down.
I guess I'm asking for some Windows API calls that can negotiate with Windows to kill the process last if possible, but any working solution is welcome. The Client is written in C# and the Server is written in C++.
The Server should be keeping track of the Clients that are connected to it. So, if your apps are busy performing housecleaning, they ARE blocking shutdown, even if just momentarily. So what is wrong with letting Windows show a message to the user saying that?
When the Server gets notified of an imminent shutdown, have it call ShutdownBlockReasonCreate() if there are any Clients connected. Regardless of whether the Clients perform housecleaning or not, when the last Client disconnects then the Server can call ShutdownBlockReasonDestroy().
The obvious solution is to make the server a Windows service.
As a stop-gap solution you can try SetProcessShutdownParameters.
This function sets a shutdown order for a process relative to the other processes in the system.
I have an API application and a web application (for simplicity on the same server -- I'll do the CORS stuff later).
Windows Server 2012 with IIS 8.5
Websockets installed through "Programs and features"
Firewall turned off
The api is using owin + signalr and has the proper initialization (trimmed it down to find the error):
public void Configuration(IAppBuilder app)
{
GlobalHost.Configuration.TransportConnectTimeout = TimeSpan.FromSeconds(5);
app.MapSignalR();
app.UseWebApi(Startup.CreateConfiguration());
}
private static HttpConfiguration CreateConfiguration()
{
HttpConfiguration configuration = new HttpConfiguration();
configuration.MapHttpAttributeRoutes();
return configuration;
}
Everything seems to work perfectly except connection to the actual websockets. Every time the client tries to establish a connection, there is a timeout and it fails over to SSE (or forever frame/long polling in IE). I increased the timeout to 25 seconds and the same symptoms are occurring.
On the client, I consistently get this error with logging turned on:
SignalR: Connecting to websocket endpoint 'ws://[myurl]'.
SignalR: Websocket opened.
SignalR: **webSockets timed out when trying to connect.**
SignalR: Closing the Websocket.
SignalR: Attempting to connect to SSE endpoint 'http://[myurl]'.
SignalR: EventSource connected.
SignalR: serverSentEvents transport selected. Initiating start request.
SignalR: The start request succeeded. Transitioning to the connected state.
I have tried following the guides provided by the signalR team and I cannot see what I am missing.
Thanks for any help!
UPDATE:
I downloaded a sample and ran it as-is on the server.
Same situation, so this is likely a server configuration setting that I missed along the way. I still have not found what I missed.
You need to enable WebSockets for the website in Server Manager.
http://www.iis.net/learn/get-started/whats-new-in-iis-8/iis-80-websocket-protocol-support
Try establishing a SignalR connection from your Windows Server machine itself. This might have something to do with the network. Perhaps there's a proxy or something in between the client and server that doesn't properly support WebSockets.
If you are inside of a network with a "corporate" firewall, it can screw up the websockets handshake.
But, you can prevent this interference if you access your server over SSL. I've seen this first hand be the cause and solution multiple times for websockets problems in corporate environments.
It may be something with your IIS settings. I saw these on http://www.asp.net/signalr/overview/signalr-20/getting-started-with-signalr-20/supported-platforms
-IIS must be running in integrated mode; classic mode is not supported. Message delays of up to 30 seconds may be experienced if IIS is run in classic mode using the Server-Sent Events transport.
-The hosting application must be running in full trust mode.
Also, it mentioned something about .NET 4.5 being the target framework. Hope this helped.
I am doing a simple bonjour broadcast using NSNetServices. Everything is working great when I start and stop the bonjour sharing at application launch/quit. However if I turn off bonjour using the stop method call, my app still appears to be broadcasting a dead service even after the netServiceDidStop: delegate message gets called, which prevents restarting of the service until after a relaunch of the app. Apple's documentation makes it look very straightforward, just publish or stop as needed... Am I missing something?
It seems that sometimes services are shown even when they are no longer available.
From Apple documentation:
Because failing to show a valid service is a bigger problem for the user than showing a stale service, Bonjour deliberately errs on the side of assuming that a service is still available.
.
.
although Bonjour generally discovers new services within a few
seconds, if a service goes away, the disappearance of the service may
not be discovered until your app tries to connect to it and gets no
response.
You should not assume that just because the Bonjour APIs report a
discovered service, the service is guaranteed to be available when the
software tries to access it.
Connecting to and Monitoring Network Services: When resolving fails
I am using a WCF service to administer a windows service running on a remote machine. We have an administration client we use for modifying the windows service configuration, as well as monitoring the state of the service in real-time. For the real-time monitoring, we poll the service for it's state every second.
Currently, we are leaving the client connected all the time while monitoring the service but I continually read that it is recommended to connect and disconnect for each call, much like you would for a database.
Would it be recommended in our situation where we are making frequent calls to the service, or would connecting and disconnecting add too much overhead to the process?
Thanks
By default and as a recommended best practice, you're using the per-call activation in WCF, e.g. each request to your WCF service gets a new instance of a service class, that instance handles your request, returns a result, and then is disposed.
In this case, I don't really see any point in constantly breaking and re-establishing the communication channel (e.g. constantly disposing and re-creating the proxy client). There's nothing on the WCF service side that "lingers around" in memory and takes up resources or anything like that. Also, contrary to most databases, there's usually no "per-connection" licensing or anything involved, either.
What you need to be able to deal with in this scenario would be a situation where your communication channel goes into "faulted state", e.g. when something bad happens - when the service call fails and throws an exception, or when a network fluke causes your channel to break. In such a case, you need to have recovery mechanisms on your client side to handle this and re-establish the connection again.
The situation might be a bit different if you have session-oriented WCF services - but those should definitely be the exception, and only used when needed by all means.