I am unable to make On Premise API calls from MS Bot (v4) C# once deployed on Azure. The On Premise API call works fine when locally tested with emulator.
As recommended by Microsoft support team, I have already tried using Direct Line channel for web chat but does not help.
AppContext.SetSwitch("System.Net.Http.UseSocketsHttpHandler", false);
HttpWebRequest webRequest = HttpWebRequest.CreateHttp(updatedURL);
webRequest.Method = currentStep.StepsServiceCall.Method;
webRequest.ContentType = "application/json";
webRequest.KeepAlive = true;
if (!String.IsNullOrEmpty(currentStep.StepsServiceCall.Headers))
{
string updatedJson = currentStep.InjectPropertyValuesJson(currentStep.StepsServiceCall.Headers, properties);
webRequest.ContentLength = updatedJson.Length;
using (var streamWriter = new StreamWriter(webRequest.GetRequestStream()))
{
streamWriter.Write(updatedJson);
streamWriter.Flush();
streamWriter.Close();
}
}
using (HttpWebResponse response = webRequest.GetResponse() as HttpWebResponse)
{
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
{
string content = reader.ReadToEnd();
return await currentStep.ProcessResponseText(context, cancellationToken, content);
}
Getting below error from Azure App Service logs.
Microsoft.Bot.Builder.Integration.AspNet.Core.BotFrameworkHttpAdapter: Exception caught : An error occurred while sending the request. Error 12029 calling WINHTTP_CALLBACK_STATUS_REQUEST_ERROR, 'A connection with the server could not be established'.