I'm not entirely sure how to even ask this question, so here's the situation:
We have a single-page application that connects to a SignalR hub that uses CORS for cross domain authentication
The user connects to the hub and leaves their browser window open
We delete the user, but since they already connected to the hub, anytime they go back to that page (without reloading), the hub reconnects
Restarting IIS has no effect
So that's the situation and I think I understand why it's happening, what I don't know is the best practice for keeping this from happening in the future (I originally thought expiring the session but since this is a single page application as long as they don't refresh, it'd never call the session timeout).
Is there an easy way server side to kill a connection (we log all connections so have connection ids, etc)?
Thanks for the guidance! I'm stuck.
You cannot stop a connection from server side. To stop the connection, you need to call $.connection.hub.stop(); from the client side
One way to stop the connection is to create a function in Client side, then call it from Server
Client Side
myHub.client.serverWantDisconnect = function (value) {
$.connection.hub.stop();
};
Server Side
Clients.Client(Context.ConnectionId).serverWantDisconnect();
Related
When you have a meteor cluster (lets say 2 boxes) and a server stops responding (goes down), does all the traffic get re-routed to the other "live" server? I'm building an application for someone that it is very likely will be a fire and forget application (where it runs and just provides updates when they come in).
My concern is that if one server goes down, there won't be any traffic to any of the clients that were attached to that box.
Info about app:
The app will be a fire and forget (load page and walk away). Likely someone won't refresh the page or anything.
This app is mission critical and someone not getting a notification is really, really bad, and a difference of a few seconds does matter.
Websockets must be used. The 10 second dely in pull-logging is unacceptable.
Most Importantly....
The app must auto recover. If a server goes down, the client must switch to a good box without a page refresh or someone walking over to the box and causing the refresh.
Meteor has will always try to reconnect to the server when a connection is lost, So if the server gets back online it will reconnect. But if you need a custom logic to retry a connection to different cluster when the user disconnect should also be easily coded the docs have reactive API to see the connection status (Meteor.status) here is a new package I found it can be a great place to see how it should work: https://github.com/nspangler/autoreconnect
also if you're using meteorhacks:cluster it's possible it will retry to connect to a different server, the docs don't really say anything about it but if it's not I think aruonda might add that just by asking on git.
good luck :)
I am using Signalr in an application I'm writing and storing all the user connections in a concurrent dictionary
ConcurrentDictionary<string, User> _users = new ConcurrentDictionary<string, User>();
e.g.
https://github.com/SignalR/SignalR/blob/master/samples/SignalR.Hosting.AspNet.Samples/Hubs/ShapeShare/ShapeShare.cs
I have implemented the IDisconnect interface on my Hub and I'm removing users from the dictionary when they disconnect
I am wondering how reliable the Disconnect method really is?
Does it capture all the different ways that a user could diconnect?
I dont want the dictionary to grow and grow indefinitely
I was thinking of maybe having a timer to periodically traverse the dictionary and remove users who havent had any recent activity
Is this necessary? Can I rely on the disconnect method?
Check out https://github.com/SignalR/SignalR/wiki/Configuring-SignalR , there are settings for :
DisconnectTimeout
KeepAlive
& Heatbeat interval
These could all be applied to help in maintaining your dictionary.
In my experience a graceful disconnect seems to work perfectly on signalR (still problems with win-apps) , if it ungracefully disconnects in a few minutes the connection will timeout and the disconnect method will fire and remove it from your dictionary like Drew said.
You could create a method that sends a message to all clients and log the returned connection ID and then remove any entries that are old, but in practice the disconnect method does work/work itself out, I would only implement the heartbeat interval if you really need to keep a very close eye on the connections.
If it doesn't fire it's a bug and you should report an issue to the SignalR project on GitHub. Here's a list of open issues with Disconnects at this time.
Be aware that diff. transports have diff. disconnect detection logic and so, depending on which transport the user is using, you will see diff. patterns of when the Disconnect fires, but it SHOULD fire eventually for all transports.
I have an ASP.Net C# web application, running on IIS, that I'm supporting which involves generation of word documents. Some of these word documents take a very long time (i.e. upwards of 20-30 minutes) to generate. What I notice while testing on my dev server is that the server closes the connection long before the process completes, the server-side ASP.Net code itself enters a loop and updates the status of a boolean value when the word doc generation completes.
My workaround for this is to keep the connection alive by implementing a dynamically animated wait screen ( using jquery and ajax) on the client-side that's updated by a repeated asynchronous AJAX call to the server that checks on the status of the operation from a server-side web method. I'm asking about that piece in another question.
Is the solution I'm looking at implementing the best approach to this problem? Are there more efficient or common methods for keeping the connection alive during a long running server-side operation? Any help or insight is appreciated, thanks.
UPDATE:
I tried Brian's suggestion, unfortunately I still get the same error from Chrome that no data is being sent from the server and the entirety of the error is as follows:
No data received Unable to load the webpage because the server sent no
data.
Here are some suggestions: Reload this webpage later.
Error 324 (net::ERR_EMPTY_RESPONSE): The server closed the connection
without sending any data.
I'll try again by setting the connection timeout in the advanced website settings as described and increasing the connection idle setting.
Ideally, you'd use a socket to notify the client when the process completes. Look at socket.io or native web-socket implementations on how to do this.
You can control Idle time within IIS 7. This is done by going to IIS management; select application pools; then right click on the pool your using for your website. Click the "Advance settings" here you will be able to control idle time out and some other settings for your website. Hope this is what your looking for.
Does anyone know a standard way to keep alive the http session as long user has open the flex app in the browser?
I played around with the polling mechanism of blazeds. But it had no affect on the http session.
Why do you need the http session to stay alive?
We have authentication enabled in our flex-weborb-.net application. If the session is terminated, the next call to weborb will throw a security exception. In this case we just re-authenticate and do the server call again. A new session is created and the user can continue his work. Like this, no polling is needed. I guess it's the same with blazeds.
If the session must stay the same, then I would suggest to ping the server every couple of minutes depending on the session timeout value.
There is no standard way of doing this. We do a ping-pong with the server every n-seconds (check the AS3 Timer class), where n must be lower than the session timeout. It's best to keep your session timeout as low as possible to reduce memory consumption on the server, especially when you have a lot of concurrent users.
One option is to submit an AJAX keepalive request from javascript in the hosting HTML page.
I am working on a project that uses the asp.net ajax control toolkit and all my callback requests are hanging till the request times out. When I step through the code all my code executes then the hanging occures. Right now I am looking for possible reasons why this might happen.
If the request takes significant time, it is possible that the client-side AJAX request is timing out before your server-side code completes. At that point the client has dropped the connection and the server can no longer communicate with it. Can you look into increasing the timeout value on the client to something really big to eliminate this as a possibility?
Firewall or NAT? Something on the network might be blocking return calls from getting back to you.
Check if the callback address you are providing is valid to the server. For instance, the server may not be able to translate some host name or DNS entry.