Search code examples
c#asp.netweb-servicesconnectionbandwidth

C# application testing connection (ping, download, upload) to the web service


I have created a simple web service that receives data and saves it in a database. I need to create an application (or service) that will test the connection to this web service (from time to time, e.g. every 1 minute).

I need information like download, upload, ping and save them in the database. I tried NetworkInterface, but the web service is not an interface, so it cannot find it. I don't know how to test this connection and get information about it, so I need help.


Solution

  • Solution 1: fully custom

    High level description:

    1. Create a new endpoint , something like api/healthcheck
    2. Either a. do a mock action (save/delete false data b. Maintain a table or any other persistence (even a singleton would do) with statistics from recent calls
    3. Add them to a class response object and return it to the caller.

    Solution 2: Use custom telemetry

    High level description:

    1. Pick a service like application insight: https://learn.microsoft.com/en-us/azure/azure-monitor/app/app-insights-overview
    2. Configure the telemetry if the out of the box configuration isn't enough.
    3. Use the rest api to get your information