Error Vb.NET DLL Accessing Query API in Microsoft Azure

Felix Melo 1 Reputation point
2021-06-13T03:56:47.727+00:00

When I run a DLL (in AutoCAD) to access a table in my database in Azure the following error occurs:

System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: An attempt was made to access a socket in a way that is prohibited by access permissions 191.235.228.33:443
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
--- End of inner exception stack trace ---

I tested it as an EXE (external executable) and it works.
I tested the API in the browser and it works.
In both cases (DLL and EXE) I tested HttpWebRequest, WebClient, and HttpClient.

The IP presented in the error message I found in my account if service in Microsoft Azure.

Follow the code in VB.NET using HttpWebRequest:

Dim JSURL As String = "https://microcad.azurewebsites.net/teste/T269999"
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls '<<< TSL=1
Dim request As HttpWebRequest = CType(WebRequest.Create(JSURL), HttpWebRequest)
request.Credentials = CredentialCache.DefaultCredentials
request.Proxy = Nothing
request.Timeout = 15 * 1000
Dim response As HttpWebResponse = CType(request.GetResponse, HttpWebResponse) '<<<ERROR
Dim dataStream As Stream = response.GetResponseStream()
Dim reader As New StreamReader(dataStream)
Dim JSON As String = reader.ReadToEnd()
reader.Close()
response.Close()

Grateful,
FELIX MELO

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,714 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,674 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. SnehaAgrawal-MSFT 21,346 Reputation points
    2021-06-16T10:58:03.333+00:00

    Thanks! looking at the App performance and availability, HTTP 500 error is coming directly from the App Container. HTTP 500.0 error typically indicates an application code issue. An un-handled exception in the application code or an error in application is what typically causes this error. Try checking latest logs from the Application logging.

    Also its suggested for applications that are accessed infrequently and are sensitive to start-up delay's, please enable AlwaysOn by following the steps below.

    1. Navigate to the webapp on Azure Portal.
    2. Scroll down in the left hand side menu and click on Configuration.
    3. Navigate to General settings tab.
    4. Set Always on to On under Platform settings.
    5. Click on Save.

    Also refer to discussion here might helps.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.