c# - Restsharp: Underlying connecion has been closed -


i having trouble using restsharp client in windows service. when api down connection lost. once api runs again, rest client keeps throwing same error. if set new instance of restclient.

anyone same problem , working solution or proposal?

i'm colleague of ludwig. our application starts , connects api, application keeps running , calling api. when api down (restarted) our application gets error: the underlying connection closed: connection expected kept alive closed server , call initodataclient , readconfigasync functions recreate restclient. when api running again expected restclient work again keep getting: the underlying connection closed. not establish secure channel ssl/tls when restart our application works again. there no certificate problems. seems creating new restclient object uses old (invalid) connection of code use:

private restclient restclient;      private void initodataclient()     {         restclient = new restclient(options.baseurl);         restclient.adddefaultheader("authorization", "bearer " + options.accesstoken);     }      private async task readconfigasync()     {             var requestapplication = new restrequest("applications/" + guid.parse(applicationid));             var response = await restclient.executegettaskasync<application>(requestapplication); //here response contains underlying connection closed error     }      public async task restartasync()     {         stop();                 {             try             {                 logger.log("trying reconnect server in 5 seconds...");                 thread.sleep(5000);                 initodataclient();                 readconfigasync().wait();                 break;             }             catch (exception) { }         }         while (true);     } 

Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -