I don't seem to be able to get my PC (Windows 7) to listen to any inbound information. Though outbound is working fine. I disable firewall and try many things. Here are my previous questions on the matter: Simple TcpListener hanging and https://stackoverflow.com/questions/20410898/enable-tcp-listening-on-a-pc .
I now put up a simple site on the PC's iis with a generic handler (ashx) as it comes "out of the box".
And here's a web page's codebehind to access that ashx page:
using (var wc = new WebClient())
Label1.Text = wc.UploadString("http://localhost/Listener/Handler1.ashx", "hi");
The web page shows the ashx's "hello world" message fine if it (the page) is executed in Visual Studio. However - when I upload it to my website (changing localhost to my ip as Google shows me) - it doesn't get any response from the ashx page. Why?
(I tried using HttpListener as was suggested to me in comments but got permission error messages. And anyway - this example now seems to indicate the problem lies elsewhere - specifically - that the computer is somehow not 'configured' to accept any inbound traffic.)
More information: The PC is connected to the internet via a wireless router. Does that make a difference?
Related
I have a self-hosted SignalR application in a Windows Service built with VS2015 FW 4.6, SignalR 2.3.0. This has been working fine for more than 2 years using ports 6286 (https) and 6287 (http) and "*" for the IP. I wanted to switch these ports to 80 and 443 respectively and apply a wild-card certificate to 443. Since there are web sites using the certificate on IP 192.168.100.7 I added another IP address (192.168.100.3) to my server applied the certificate with:
netsh http add sslcert ipport=192.168.100.3:443 appid={12345678-db90-4b66-8b01-88f7af2e36bf} certhash=xxxxxxxxxxxxxxxxxxxxxxxxx
I can verify the success with:
netsh http show sslcert ipport=192.168.100.3:443
So I start the WebApps with the following:
SignalR = WebApp.Start("http://192.168.100.3:80/");
SignalRSSL = WebApp.Start("https://192.168.100.3:443/");
They seem to start fine, no errors and if I use http://192.168.100.3/signalr/hubs it works fine. However, https://192.168.100.3:443/signalr/hubs gives the "Unexpectedly closed connection" error.
What have I done wrong, is there something else to set for https?
My error... I was using the internal IP's and corresponding external IP's to test this. What I realized is that the wild-card certificate is not tied to an IP, it's tied to a domain! So, I created an A record for the IP with the wild-card's domain and it worked.
However, I now have a different problem in that it's trying to negotiate with the web server's domain and not the signalR domain to send a message!
https://webserverdomain/signalr/negotiate?clientProtocol=1.5....
I don't know where it's picking the web server's name up but it's different enough that it's probably a topic for another post.
I am working on uwp app. I edited hosts file and redirecting www.example.com to local server IP(192.168.1.187). In browser website is loading properly but in application
System.Net.Dns.GetHostAddresses("https://www.exaple.com")[0]
Throws System.Net.Sockets.SocketException
If I remove http/https, it is working
System.Net.Dns.GetHostAddresses("www.exaple.com")[0]
output => 192.168.1.187
I want to specifically make a request to https://www.example.com.
System.Net.Dns.GetHostAddresses does hostname resolution. It is very similar to ping in command line. You can test, that using
ping www.example.com
Will give you response while
ping https://www.example.com
will not.
As for the fact that you cannot issue a HttpClient request to http://www.example.com, it might be because you don't have the appropriate capability set. Go to Package.appxmanifest, click the Capabilities tab and check the Private Networks (Client & Server) capability.
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've been trying get my app to connect to a WCF service within the corporate network.
We use a VPN to keep everything somewhat hidden and secure.
I've tried several different methods and I'm unable to get the phone to connect to the service.
I first added the service as a service reference, and built the client out with the correct URL, but this just did nothing and then failed with a nondescript error message after around 50sec.
I then switched to System.Net.HttpClient. This again failed after around 50sec, but this time it threw a System.Net.WebException with the message "A server with the specified hostname could not be found".
I finally tried the ModernHttpClient as well, and this had the same result as before.
(Note that I tried the first two in a test console app project on my local machine first to make sure that they would complete a request successfully)
To make sure I wasn't going crazy and that the VPN was correctly resolving the name, I created a test page within the app which solely has a WebView on it, with the source set to the service url.
I opened the app and navigated to the test page and it loaded the service definition page without a problem.
for reference, this is the current code I have using ModernHttpClient:
using (var client = new HttpClient(new NativeMessageHandler()))
{
const string soap = "<soap msg>";
client.DefaultRequestHeaders.Add("SOAPAction", "<service namespace>");
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("text/xml"));
using (var response = await client.PostAsync("http://<url>/Service.svc", new StringContent(soap, Encoding.UTF8, "text/xml")))
{
using (var content = response.Content)
{
// parse the xml result
}
}
}
Is there something special that I should be doing to tell the HttpClient that it has to use the VPN? I thought that this was handled automatically.
I looked into the VPN configuration to make sure it was correct.
I looked into the DNS configuration to make sure it resolves correctly.
I looked into the phone's configuration to make sure it was correct.
I eventually found the issue is a problem with Airwatch's Tunnel VPN.
The VPN only works the first time the app is launched.
If the VPN remains open and is not closed before the app is restarted, then it will not allow connections to pass through.
Expecting a patch form airwatch soon that should (hopefully) rectify the issue!
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...