Connect to Azure Storage blob Behind Proxy: The proxy tunnel request to proxy 'http://ipaddress:port/' failed with status code '407' - proxy

Follow code available on Microsoft documentation portal but what if I want add the proxy to it? I'm using .NET Core 6+
string blobstorageconnection = pConfig.AzuerBlobStorageConnectionString;
CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(blobstorageconnection);
CloudBlobClient? blobClient = null;
CloudBlockBlob? blockBlob = null;
blobClient = cloudStorageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference(pConfig.AzureStorageContainerName);
blockBlob = container.GetBlockBlobReference(pFileName);
await blockBlob.UploadFromFileAsync(pFilePath + #"\" + pFileName);
I tried above code and it is working fine without proxy setting in network but as we enable the proxy setting system raise the error : "The proxy tunnel request to proxy 'http://ipaddress:port/' failed with status code '407'."

Related

connect to local endpoint (laravel) from flutter with physical device

For some unknown reason I can't connect to local endpoint on physical device.
Code:
String url = 'http://localhost/eltriodigital/public/api/prueba';
String url2 = 'http://192.168.56.1/eltriodigital/public/api/prueba';
String url3 = 'https://ecleectic.com/api/prueba';
Future<Response> prueba() async {
Response response =
await get(url, headers: {'Content-type': 'application/json'});
return response;
}
Tests I have performed:
If I try to connect to a production endpoint(url3) it works.
If I try to connect to local endpoint(url,url2) but from emulator it works.
If I try to connect to local endpoint(url,url2) from flutter web if it works.
Can someone tell me why I can not connect from physical device in local endpoint(url,url2)? Thanks
Can you check this question
How can I access my localhost from my Android device?
It may has the solution for your problem

Unable to send email when under Docker environment

I'm unable to send an email when under Docker environment but if I tried running my application outside of Docker. It works.
I tried exposing the SMTP port from Docker but still failed
Here is my email function:-
SmtpClient client = new SmtpClient("myhost", 587);
client.UseDefaultCredentials = false;
client.Credentials = new NetworkCredential("email#example.com", "password");
MailMessage mailMessage = new MailMessage();
mailMessage.From = new MailAddress("email#example.my");
mailMessage.To.Add(email);
mailMessage.Body = "message";
mailMessage.Subject = "Subject";
mailMessage.IsBodyHtml = true;
client.Send(mailMessage);
I got a "Socket Exception: This is usually a temporary error during hostname resolution and means that the local server did not receive a response from an authoritative server."

Minio Received non-HTTP message from new connection

server error:
Received non-http message from new connection
client error:
code:
var endpoint = "127.0.0.1:9000";
var accessKey = "MFQD47M******R5TZ1";
var secretKey = "WsuNQtYs********npA7iMRLjRmx";
var minio = new MinioClient(endpoint, accessKey, secretKey).WithSSL();
await minio.ListBucketsAsync();
Try removing .WithSSL(). It seems like your server is expecting plain HTTP, but your client is expecting HTTPS. First try changing the client to plain HTTP. If that works, you'd probably want to properly enable HTTPS on your server so you have a secure connection.
https://docs.minio.io/docs/how-to-secure-access-to-minio-server-with-tls

413 Request Entity Too Large For HttpClient

Once i send the HttpClient request through the PostAsJsonAsync i get the response as Request Entity too large. but i can directly call to webapi and send the request and returns a successfull response. but through the PostAsJsonAsync it returns the 413 error code.
This is my code
var client = new HttpClient { BaseAddress = new Uri(ConfigurationManager.AppSettings.Get("API_HOST")) };
const string api = "CmSaveChange" + "/" + "SaveChange";
var response = client.PostAsJsonAsync(api, entity).Result;
var retunValue = response.Content.ReadAsAsync<HybridDictionary>().Result;
The problem has to be solved on the server-side (self hosting HttpSelfHostServer or IIS).
The buffers have to be set to a higher value.
If the host run's under IIS:
Configure IIS
If the server is running as HttpSelfHostServer:
You have to set higher values (as needed) to the config parameters.
Example for vb.net
Dim cSelhostConfiguration As String = cIPADressePort
' Note: cIPADressePort contains the IP address and port on which the host is listen
Dim config As New HttpSelfHostConfiguration(cSelhostConfiguration)
'Set here the needed size (in bytes)
config.MaxBufferSize = 250000000
config.MaxReceivedMessageSize = 250000000
'
config.Routes.MapHttpRoute(
name:="DefaultApi",
routeTemplate:="api/{controller}/{id}",
defaults:=New With {.id = RouteParameter.Optional}
)
'
Using server As New HttpSelfHostServer(config)
Try
server.OpenAsync().Wait()
Console.WriteLine("")
Console.WriteLine("WebService started... ")
Console.WriteLine("Waiting for work...")
Catch aggEx As AggregateException
Console.WriteLine("Error loading Server")
End Try
Console.WriteLine()
Console.WriteLine("Press enter to close the server")
Console.ReadLine()
End Using

Unable to see http traffic from/to my NodeJS app in Charles [mac]

I am running Charles to inspect HTTP traffic between a node js client and a service running locally on my machine (a Mac). I am able to access the service but don't see any trace in Charles. I have tried replacing localhost with my machine's IP name but still no trace. If I type the service URL in Chrome I do see a trace. Anyone knows how to fix this?
Here is my nodejs code:
var thrift = require('thrift'); // I use Apache Thrift
var myService = require('./gen-nodejs/MyService'); // this is code generated by thrift compiler
var transport = thrift.TBufferedTransport();
var protocol = thrift.TBinaryProtocol();
var connection = thrift.createHttpConnection("localhost", 5331, {
transport : transport,
protocol : protocol,
path: '/myhandler',
});
connection.on('error', function(err) {
console.log(err);
});
// Create a client with the connection
var client = thrift.createHttpClient(myService, connection);
console.log('calling getTotalJobCount...');
client.getTotalJobCount(function(count)
{
console.log('total job count = ' + count);
});
and my proxy settings:
fixed this myself with help of this link. Charles intercepts the traffic crossing the system proxy which is 127.0.0.1:8888 on my mac. Here is proper code:
// give path to the proxy in argument to createHttpConnection
var connection = thrift.createHttpConnection('127.0.0.1', 8888, {
transport : transport,
protocol : protocol,
path: 'http://localhost:5331/myhandler', // give the actual URL you want to connect to here
});
In addition need to use thrift.TBufferedTransport instead of thrift.TBufferedTransport() and thrift.TBinaryProtocol instead of thrift.TBinaryProtocol()

Resources