I have written a simple RabbitMQ Publisher with help from RabbitMQ .NET Client. Basically we have this internal app, and when that wishes to send out emails, I want the emails to be published onto a RabbitMQ Queue, where another consumer app (console app running as a windows service) would then pick those emails up and send them off via SMTP.
This all works fine locally when I use localhost as HostName and the default guest account. But when I change things to the RabbitMQ Test Server, I get an error:
<add key="RabbitMQ.HostName" value="rabbit#XXXXX-LTXXX01"/>
<add key="RabbitMQ.UserName" value="adminAccount"/>
<add key="RabbitMQ.Password" value="adminPassword"/>
<add key="RabbitMQ.QueueName" value="DigitalEmails"/>
<add key="RabbitMQ.ExchangeName" value="DigitalEmailsExchange"/>
<add key="RabbitMQ.RoutingKey" value="DigitalEmail"/>
The error I get says:
RabbitMQ.Client.Exceptions.BrokerUnreachableException - None of the specified endpoints were reachable
It sounds like a permission issue, but I have looked at the adminAccount and he seems to be setup like guest is. With all permissions granted.
Why is this happening?
UPDATE
I tried ping that HostName and I got:
I'm trying to get a stateless service to send a value to another, just to achieve communication between services by using the DNS-service in service fabric. I've tested both applications with postman, and they work fine. I'm following this tutorial where it seems pretty straight forward to do this.
The DNS-service is enabled:
The stateless service has a DNS-name:
The DNS-name is configured in the ApplicationManifest.xml
<Service Name="SocketService"
ServiceDnsName="SocketService.TimeSeriesActorApplication"
ServicePackageActivationMode="ExclusiveProcess">
<StatelessService ServiceTypeName="SocketServiceType"
InstanceCount="[SocketService_InstanceCount]">
<SingletonPartition />
</StatelessService>
</Service>
I then try to send a http get to the service, just like in the tutorial.
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("http://socketservice.timeseriesactorapplication:8712/api/");
var response = await client.GetAsync("values");
}
But I get an exception:
WebException: The remote name could not be resolved: 'socketservice.timeseriesactorapplication'
This happens both when I use port 8080 like the tutorial suggests, and when I use the port I specify in ServiceManifest.xml.
<Endpoints>
<Endpoint Protocol="http" Name="ServiceEndpoint" Type="Input" Port="8712" />
</Endpoints>
What am I missing here?
Update:
Using localhost instead of dns-name also works fine.
Issue on Github: Unable to resolve service DNS name #332
I see you are running service fabric 5.6.210. The recent 5.6.220 release (https://blogs.msdn.microsoft.com/azureservicefabric/2017/06/20/release-of-sdk-2-6-220-and-runtime-5-6-220-refresh-for-windows/) contains some fixes for the DNS service. Note that even though I am running 5.6.220, I have noticed that the DNS name resolution does not always seem to start working straight away after deployment on my local machine (I have to redeploy or wait a few minutes). If you are running locally you can test the name resolution in a terminal window - just ping your service's DNS name.
I fixed it by using ipconfig /flushdns to refresh DNS.
I also found that local IP is the first DNS server in my DNS chain.
I'm writing a small C# reporting application for TFS 2012.
TFS server is remote and can be accessed only via HTTP proxy server in the network, as firewalls block direct access.
The proxy is configured in Internet Explorer, so I can open TFS URL in IE, and also it's automatically used by Visual Studio when working with TFS.
The problem is that my application ignores IE proxy settings and tries to connect to TFS server directly (I see this in Wireshark), so it fails after a timeout due to firewalls.
Here is the code I use:
Uri TfsCollectionURL = new Uri("...");
NetworkCredential credential = new System.Net.NetworkCredential(Username, Password, Domain);
TfsTeamProjectCollection collection = new TfsTeamProjectCollection(TfsCollectionURL, credential);
collection.EnsureAuthenticated();
ICommonStructureService projectService = collection.GetService<ICommonStructureService>();
foreach (ProjectInfo project in projectService.ListProjects())
{
...
}
Application fails at .EnsureAuthenticated() with exception:
TF400324: Team Foundation services are not available from server ...
A connection attempt failed because the connected party did not
properly respond after a period of time, or established connection
failed because connected host has failed to respond ...
It does work from another subnet where direct access to the TFS server is allowed.
QUESTION:
How can I use HTTP proxy in my C# application for connection to TFS?
Try adding an App.config file to set the default proxy with the following code:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.net>
<defaultProxy enabled="true" useDefaultCredentials="true"></defaultProxy>
</system.net>
</configuration>
You can directly set credentials to pass the proxy:
WebProxy p = new WebProxy("proxyserver.domain.com:8080", true);
p.Credentials = new NetworkCredential("domain\\user", "password");
WebRequest.DefaultWebProxy = p;
In my scenario we have a subnet for development and those accounts/machines are not allowed to access the internet. Therefore we need to enter the upper domain proxy and those domain credentials to get access to internet.
I am using the following code which is working on local machine, but when i tried the same code on server it throws me error
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection
failed because connected host has failed to respond
Here is my code:
WebClient client = new WebClient();
// Add a user agent header in case the
// requested URI contains a query.
//client.Headers.Add ("ID", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
Stream data = client.OpenRead("http://" + Request.ServerVariables["HTTP_HOST"] + Request.ApplicationPath + "/PageDetails.aspx?ModuleID=" + ID);
StreamReader reader = new StreamReader(data);
string s = reader.ReadToEnd();
Console.WriteLine(s);
data.Close();
reader.Close();
I am getting error on
Stream data = client.OpenRead("http://" + Request.ServerVariables["HTTP_HOST"] + Request.ApplicationPath + "/PageDetails.aspx?ModuleID=" + ID);
is it due any firewall setting?
I had a similar problem and had to convert the URL from string to Uri object using:
Uri myUri = new Uri(URLInStringFormat, UriKind.Absolute);
(URLInStringFormat is your URL)
Try to connect using the Uri instead of the string as:
WebClient client = new WebClient();
client.OpenRead(myUri);
setting the proxy address explicitly in web.config solved my problem
<system.net>
<defaultProxy>
<proxy usesystemdefault = "false" proxyaddress="http://address:port" bypassonlocal="false"/>
</defaultProxy>
</system.net>
Resolving the “TCP error code 10060: A connection attempt failed…” while consuming a web service
I know this ticket is old, but I just ran into this issue and I thought I would post what was happening to me and how I resolved it:
In my service I was calling there was a call to another web service. Like a goof, I forgot to make sure that the DNS settings were correct when I published the web service, thus my web service, when published, was trying to call from api.myproductionserver.local, rather than api.myproductionserver.com. It was the backend web service that was causing the timeout.
Anyways, I thought I would pass this along.
I know this post was posted 5 years ago, but I had this problem recently. It may be cause by corporate network limitations. So my solution is letting WebClient go through proxy server to make the call. Here is the code which worked for me. Hope it helps.
using (WebClient client = new WebClient())
{
client.Encoding = Encoding.UTF8;
WebProxy proxy = new WebProxy("your proxy host IP", port);
client.Proxy = proxy;
string sourceUrl = "xxxxxx";
try
{
using (Stream stream = client.OpenRead(new Uri(noaaSourceUrl)))
{
//......
}
}
catch (Exception ex)
{
throw;
}
}
Adding the following block of code in web.config solves my problem
<system.net>
<defaultProxy enabled="false" >
</defaultProxy>
</system.net>
In my case I got this error because my domain was not listed in Hosts file on Server.
If in future anyone else is facing the same issue, try making entry in Host file and check.
Path : C:\Windows\System32\drivers\etc
FileName: hosts
Is the URL that this code is making accessible in the browser?
http://" + Request.ServerVariables["HTTP_HOST"] + Request.ApplicationPath + "/PageDetails.aspx?ModuleID=" + ID
First thing you need to verify is that the URL you are making is correct. Then check in the browser to see if it is browsing. then use Fiddler tool to check what is passing over the network. It may be that URL that is being called through code is wrongly escaped.
Then check for firewall related issues.
I had this problem. Code worked fine when running locally but not when on server.
Using psPing (https://technet.microsoft.com/en-us/sysinternals/psping.aspx) I realised the applications port wasn't returning anything.
Turned out to be a firewall issue. I hadn't enabled my applications port in the Windows Firewall.
Administrative Tools > Windows Firewall with Advanced Security
added my applications port to the Inbound Rules and it started working.
Somehow the application port number had got changed, so took a while to figure out what was going on - so thought I'd share this possibility in case it saves someone else time...
I have resolved this below issue
A connection attempt failed because the connected party did not
properly respond after a period of time, or established connection
failed because connected host has failed to respond
Solution
We need to configured proxy setting in code. my scenario using Web.config file
Added Proxy address as below
<system.net>
<defaultProxy>
<proxy proxyaddress="http://XXXXX:XXXX" bypassonlocal="True"/>
</defaultProxy>
</system.net>
Also added proxy credential using below code NetworkCredential - I have used my local credential here.
HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(url);
webReq.Credentials = new NetworkCredential("XXXX", "XXXXX");
webReq.Proxy.Credentials = new NetworkCredential("XXXX", "XXXX");
It works for me!
First Possibility: The encrypted string in the Related Web.config File should be same as entered in the connection string (which is shown above)
And also, when you change anything in the "Registry Editor" or regedit.exe (as written at Run), then after any change, close the registry editor and reset your Internet Information Services by typing IISRESET at Run. And then login to your environment.
Type Services.msc on run and check:
Status of ASP.NET State Services is started. If not, then right click on it, through Properties, change its Startup type to automatic.
Iris ReportManager Service of that particular bank is Listed as Started or not. If its Running, It will show "IRIS REPORT MANAGER SERVICE" as started in the list. If not, then run it by clicking IRIS.REPORTMANAGER.EXE
Then Again RESET IIS
I know it's an old post but I came across the exact same issue and I managed to use this by turning off MALWAREBYTES program which was causing the issue.
It might be issue by proxy settings in server. You can try by disabling proxy setting,
<defaultProxy enabled="false" />
Íf above solutions don't work for your case. May be your request drop by firewall. Check firewall settings.
I am completely new to Windows Azure.
I currently have a local db for my .NET application. I have created an azure account along with a relevant SQL Azure Database.
I am working on adding the C# code in order to pass the data from the local application to the cloud. In order to test this functionality I have added a random user who I want to insert into the Azure DB.
I have used the following tutorial: http://www.windowsazure.com/en-us/develop/net/how-to-guides/sql-database/
I are trying to connect to the Azure SQL Database using a connection string in app.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="STAREntities"
connectionString ="Server=tcp:fkr95b1any.database.windows.net,1433;Database=StarSoftwareDb;User ID=starSoft1#fkr95b1any;Password=xxxxxx;Trusted_Connection=False;Encrypt=True;" />
</connectionStrings>
</configuration>
This method is being used for registration, this code establishes the connection to the azure database, however it is currently failing on 'conn.Open();'.
SqlConnectionStringBuilder csBuilder;
csBuilder = new SqlConnectionStringBuilder(ConfigurationManager.ConnectionStrings["STAREntities"].ConnectionString);
SqlConnection conn = new SqlConnection(csBuilder.ToString());
conn.Open();
On clicking the register button which triggers this code, the program hangs for a long period before throwing the following error:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time or established connection failed because connected host has failed to respond.)
Any help or advice here would be greatly appreciated.
UPDATE
I have changed my connection string to the one #Leonardo suggested below. I have also enable 'TCP/IP' and 'Named Pipes' in sql server configuration manager aswell as allowing opening port 1433.
The dashboard for the master DB is now showing successful connections on the table but I am still getting an exception on
conn.Open()
try this here:
"Server=fkr95b1any.database.windows.net;Database=StarSoftwareDb;User ID=starSoft1#fkr95b1any;Password=xxxxxx;"
and check your firewall settings for the instance! it might be closed for all applications (default setting)