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