c# - Best practice to detect a loss of a client in an ASP.NET web application -


This is not a specific coding question, but with years the best practice for a newcomer in web applications is five Enin Telecom software development Experience in

I have an ASP.NET web application that collects data from many embedded (Ardino) devices. Push device data from time to time via simple HTTP GET requests. In normal circumstances, each device pushes the data once every 30 seconds However, it is a chance that the device can be lost or the connectivity from the device to the server can be lost to me this condition is 2-3 normal data reporting cycles Will have to find out within.

If this was a specific stand-alone C # application, then every time I get data from the device, the expiration set exceeds the timer for the maximum expiration period. , It means that I have not heard from the device for too long and I need to trigger a warning (email or something) from my application.

Therefore, the inactivity timer approach is pretty alone-always-specific for non-continuous connection applications. But what is the correct way to do this in the ASP.NET web app? Do I have such timers running outside the operators of my HTTP request?

I have searched potential solutions, and people have more questions about the time of browser sessions, and such my problem is different in these aspects:

  1. My Near session is a very light weight customer unable to position status tracking
  2. I need to periodically detect inactivity to alert /

My suggestion is first You are using to add data to the server, switch to the post. Second, try to use any type of token The first request (request received) The user creates an endpoint that they can get an access token. Then each time they connect through the post to push the data, get the access to the header access token, check whether the token has expired yet or not. If this is good, then process their request and reply with a new access token. If access tokens has expired, then go to the last point to get a new access token.

For an access token, you can set it to end after a certain time. You do something like this:

  var timeDiff = date time.utc now - accesstoken.DateTime; If (timesdiff.its> 3) // has expired // still good /  

this is something you want to do, even though the access token has something to do with it And takes code

edit

Javascript has a interval that can loop on a separate thread and There may be a delay for a clock. You can check this access token if it is ending. When a minute (or whatever) ends, signify the user

as well as some of the best servers for the server side

Comments