I'm running a windows service which downloads RSS feeds using the following code:
XmlReaderSettings settings = new XmlReaderSettings() { DtdProcessing = DtdProcessing.Ignore };
string feedXml = XDocument.Load(XmlReader.Create(url, settings));
The service doesn't run under IIS but as an independent service.
All of the sudden (I suspect an infrastructural problem) we started receiving "unable to connect to remote server" every 10-20 minutes.
The code itself hasn't changed and I'm looking for possible causes.
In an attempt to solve this, I moved the service to a different machine but the problem persisted.
Would love to get any ideas. Thanks!
The reason for this was that the exact same service was installed in a different machine in the same environment, causing two different IPs to connect to the RSS feeds. Depending on the intervals, sometimes it was OK, sometimes it was blocked by the RSS provider.
Related
I am working on a 'Smart Device Project' using .Net Framework 3.5. I am trying to connect to some Java SOAP services on a remote server.
In order to do that, I added 'Web References' to my project.
When I try to call my web service I get a WebException 'Unable to connect to the remote server' with the inner exception being 'No connection could be made because the target machine actively refused it'.
I searched quite a lot on the Web and StackOverflow and found a lot of ASP configuration and 'Unavaliable port' answers, but as I have another application using the exact same Service successfully, I can't get why the new one isn't getting through (It did sometimes through my tests so I suppose my client implementation isn't that bad)
I tried to look if there was some connection issue on the port by using some TcpClient:
System.Net.Sockets.TcpClient client = new System.Net.Sockets.TcpClient();
try
{
client.Connect("myServerName", 8087);
MessageBox.Show("Success");
} catch (Exception ex)
{
MessageBox.Show("Failure");
}
finally
{
client.Close();
}
This connection succeed.
Here is a sample on how I call my WebService:
WSServiceExtended srv = new WSServiceExtended();
srv.Proxy = new System.Net.WebProxy();
ServeurWSI wsi = new ServeurWSI();
srv.Url = "http://myServerName:8087/myServerApp/services/myService";
wsr = srv.login(wsi);
The service is called 'Extended' because I overrided the auto-generated one in order to add Cookie managment since I am using the Compact Framework. Following the sample in this thread:
https://social.msdn.microsoft.com/Forums/en-US/34d88228-0b68-4fda-a8cd-58efe6b47958/no-cookies-sessionstate-in-compact-framework?forum=vssmartdevicesvbcs
EDIT:
I made some new tests with the Web references and got it to work.
When I add the Web Reference, I have to put some Url to the Web Service. When I set it with the actual hostname instead of the 'localhost' everything is fine.
But then, since I set it manually to the real address just before the call, it shouldn't matter
srv.Url = "http://myServerName:8087/myServerApp/services/myService";
EDIT2:
I might have forgotten some specifics about my environnement.
The Web Services are exposed on my computer on some Tomcat Server.
The application I am working on is also developped on this computer (That's why I can add Web References by putting 'localhost' in the address)
The application is then deployed on a distant device (Windows CE) that will make calls the Web Services through WIFI (There, localhost wouldn't work then)
I tried calling the Web services from other computers successfully.
I'm beginning to think that there might be some differential between the called Url and the one that is set, otherwise, how would I have a difference in behaviour such as the one described in the first edit?
EDIT3:
Well..Seems like it's not a network issue but a .Net compact framework (usage?) issue...
The Url property of the Web Service implementation is simply ignored and the one in the Reference.cs is used in place.
If someone had some idea on how I could troubleshot this, I would really appreciate it.
That error means that you reached a server and the server said "no way". So you're either hitting the wrong server or the wrong port.
I find the telnet client is useful for testing stuff like this. From the command line, you can do:
telnet [servername] [port]
So something like:
telnet myServerName 8087
If it goes to a blank screen, then it connected successfully. If it does not connect, it'll tell you.
The telnet client is no longer installed by default in Windows 7+, so you'll have to install it. See here for instructions: https://technet.microsoft.com/en-ca/library/cc771275
If the connection does open, you could paste in an actual HTTP request to see what happens. A simple GET would look something like this:
GET /myServerApp/services/myService HTTP/1.1
Host: myServerName:8087
One reason for this error can be that the service binds to only a certain IP address. It could well be that the service only listens on the IP that is assigned to the host name, but not on the localhost IP (127.0.0.1).
For example:
If the host myServerName has the public IP 192.168.0.1, your service can choose to listen on all IPs assigned to the host (sometimes specifying 0.0.0.0), or it can specifically listen on 192.168.0.1 only. In that case you will not be able to connect through 127.0.0.1, because the service simply doesn't listen on that IP.
You can "use" this inverse of this feature to make a service accessible only to local clients, not on the public IP-Address, by listening on 127.0.0.1 only, but not on the public IP. This is sometimes used on Linux for example to make MySQL only accessible on the host itself.
I was starting to forget this post but I finally found the problem that was messing things up and it has nothing to do with programmation.
I was doing the calls while the device was connected to the computer via the 'Windows Mobile Device Center' allowing to access the device from Windows.
While connected, the host provided is ignored and all calls on the specified port are handled by the connected computer.
Disconnecting the device allows to communicate properly...
I am trying to get my sample WCF service to run on a on-premise HPC 2012 SP1 cluster. It's an 2012 HPC WCF application. My test service is deployed to all Compute nodes in a
cluster and configuration file is deployed on a head node too. In my client application I am using BrokerClient wrapper over my service proxy client. By using HPC Cluster
Manager I can see that my service is invoked and ran, but it is very slow, it takes him about 5 minutes to finish executing (and it's a simple test service, without intensive
operations). And also in my client application I am getting he following error after tasks finished executing on a cluster:
"Broker is unavailable due to loss of heartbeat.
Make sure you can connect to the broker node, the HpcBroker service is running on the broker node and the session is still running."
here is my client code:
SessionStartInfo info = new SessionStartInfo(this.textBox1.Text, this.textBox2.Text);
info.SessionResourceUnitType = SessionUnitType.Core;
info.Secure = false;
info.MinimumUnits = 1;
info.MaximumUnits = 1;
using (Session s = Session.CreateSession(info))
{
NetTcpBinding binding = new NetTcpBinding(SecurityMode.None, false);
using (BrokerClient<IHpcTestService> client = new BrokerClient<IHpcTestService>(s, binding))
{
ApplyCalculationsRequest request = new ApplyCalculationsRequest("test");
client.SendRequest<ApplyCalculationsRequest>(request);
client.EndRequests();
foreach (var resp in client.GetResponses<ApplyCalculationsResponse>())
{
this.label3.Text = resp.Result.ApplyCalculationsResult;
break;
}
}
}
P.S. when I try to use plain proxy client, without BrokerClient wrapper, everything works just fine.
Any ideas on the above?
Regrading the slowness, you'd need to provide more specifics about what kind of slow down you are talking about. You can see slowness in various areas and each one is caused by something different.
If it is slowness in Job Creation, this happens on the Head Node
If it is slowness in submission of tasks to job and executing EndRequests, this happens on the Broker node as the requests are written to the MSMQ folder on the broker node brokering the job.
If it is slowness in job runtime, then this is an issue with the worker nodes; this could be caused by a slow database connection, or general slowness in your application, or if you are using central shared location for the service instead of a local copy this could also cause slowness.
As for the error you are getting:
"Broker is unavailable due to loss of heartbeat. Make sure you can connect to the broker node, the HpcBroker service is running on the broker node and the session is still running."
When using the BrokerClient wrapper for whatever reason HPC sends 2 final callback messages instead of just the one. For any given job the final task in the list (but not necessarily the last executed task in the list) has a bool that designates it as the last task. When you have received all callbacks and you re-attach to the job and close it, it sends out a final message which you cannot open because the service channel was closed. I do not know why it does this when you have a BrokerClient wrapper in place; I've yet to figure that out. Essentially if I don't see that message more than once per job I ignore it at this point.
Out of curiosity can you post your code related to using a Proxy Client?
I have a windows service that needs to get data from a web page.
try
{
WebClient client = new WebClient();
byte[] test = client.DownloadData(url);
Encoding latin1 = Encoding.GetEncoding("ISO-8859-1");
string s = latin1.GetString(test);
htmlDoc.LoadHtml(s);
}
catch (Exception ex)
{
log.Fatal(ex.Message);
}
This code works perfectly fine when I'm debugging, I then install the service on my external webserver (using installutil) but when I try to launch the service it crashes on this particular line.
For some reason the error is not getting logged, so I don't understand why my code is failing. I'm guessing the service shuts down before getting into the catch.
I have also tried using HtmlAgilityPack's HtmlWeb.Load(url) but it crashed the same (which is logical I guess^^).
I've tried adding firewall security rules on the server (authorize inbound and outbound traffic on port 80) with no success.
I'm all out of ideas, any help would be greatly appreciated :)
PS: I know very little about windows services, it's the first one I have ever made.
I found out what the problem was.
The IP of my webserver must be banned from the site I'm trying to access.
I tried accessing the url using IE on my server, and the page just timed out..
My service was unable to start simply because it was taking too much time to launch due to the timed out page. It was not actually crashing, hence no exception was getting caught.
Silly me, should have tried this before. Hope this can help someone.
Cheers
This has been really painful for the last few hours and I just have no more ideas what to do.
Tried many solutions that I found on here without any luck...
I have an iis server that is hosting a wcf web service. Simple stuff.
I can connect to this (example: http://mydomain.com/Service.svc?wsdl) from the iis server and all other computers without any problems.
So I went on to make a php client on my computer - (using xampp via localhost) - (not on the iis server)
$wcfClient = new SoapClient('http://mydomain.com/Service.svc?wsdl');
$args = //input data
$response = $wcfClient->GetData($args);
print_r($response->GetDataResult->Post);
This works perfect. No problems at all. It returns all the data... Then I went on to upload this to my hosting account. This is the error I keep getting.
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from ....
I have no more ideas. Disabled firewall, changed web.config a million times and still no luck. I tried the file_get_contents method to see what's up. I keep getting:
failed to open stream: Connection refused
I just fixed this by changing the port to 80 on the iis server...
Ok, so I'm learning about ASP.NET by making a simple program to read in a user's gmail credentials and construct an email from their input into the Console, but I'm getting a new error that I was not get yesterday, and I have not changed ANY code. The error is on line 41, so I have provided that (the rest of the code is just reading input into Strings) I have disabled my firewall to no avail, and have also tried "http://localhost/Service.asmx", which doesn't work either. I've also tried restarting IIS.
I'm completely new to this subject, but the error suggests, to me, that the program is communicating with the server but is being denied by a blocked port, but I have disabled my firewall and the error persists. Any ideas? Thanks in advance!
/*40*/ Communication_Service.Service CommServiceProxy = new Communication_Service.Service();
/*41*/ Result = CommServiceProxy.SendMail(GmailAccount, Password, To, Subject, Body);
There was an error dowloading http://localhost:4932/Service.asmx. Unable to connect to the remove server. No connection could be made because the target machine actively refused it 127.0.0.1:4492
Sounds like you are running cassini (development server). The application at http://localhost:4932/ needs to be started. You probably have multiple sites and need multiple start up projects. Right click your solution and click set start up project, pick multiple, and select all your websites. On VS goto debug, run without debugging and they should all start.