WebClient server faces 503 error when accessed on LAN - c#

So I've recently copied the codes from https://www.codehosting.net/blog/BlogEngine/post/Simple-C-Web-Server
to learn about how to host a server from a C# winform. The issue is, even though the example code worked perfectly fine when I accessed localhost from my local computer, when I attempted to connect to the same server using the url http://192.168.x.x:8080/test/ from another wifi-connected computer I get error 503 : Service Unavailable.
All the similar questions I found so far on stackoverflow concerns the use of IIS. I haven't used such services, merely utilizing ASP.Net and nothing else. Previously, I had the error 504 (Bad Hostname) but that was resolved through cmd command (netsh http add url ...) , and I've also opened the port by modifying the Inbound Rule to allow connection through port 8080. However, this 503 error doesn't seem to go away...
Looking forward to any kind of help

Related

Why am I getting a 404 message from my C# webserver even after setting the appropriate URL ACL?

I have a web server built with HttpListener in C#. It is using a specific path on port 80 for GET requests being called from another C# application. It works between my development machine and a virtual machine. I set it up on another computer, and I start getting 404 responses from the server. I have the following command run to open the port and path:
netsh advfirewall firewall add rule name="Server HTTP" dir=in action=allow protocol=TCP localport=80
netsh http add urlacl url=http://+:80/svrpath/ user=%USERDOMAIN%%USERNAME% listen=yes
I cannot figure out why I keep getting 404 errors when I call a simple get to this server. If I run the server on my development machine, it works fine and the GET returns the expected json string. I have even turned off the the firewall on both sides and it continues to give me 404 errors. I have run the get command from a web browser with the same result.
I have also tried changing the user on the "add urlacl" command to values such as Everyone and Administrators to no avail.
Searching around Google has not given me any solution to this and I am looking for anyone who has any idea what could cause such a problem. All machines in question are running Windows 10 build 1709 and are connected on the local network. I'm sure there is something dumb I have missed somewhere, but I can't figure out what it is.
At this point all I can conclude is another process was locking the port so that my application was unable to respond to the requests. A restart and full re-installation of the program (including re-running all netsh commands) solved the problem and it has not recurred since doing that.

IIS Website Application doesnt work anything but port 80

I wrote a WCF service in visual studio 2017. I then added this service to IIS (not the express version but the full fledge IIS). It is added as an application under the default created website. I can access my service end-point without any issues at http://localhost/<websitename>/MyService.svc/test/123. /test/123 is just a simple GET endpoint.
The default website is already configured for port 80.
However, when I changed the port from 80 to say, 1234, it does not work. It merely returns me "Service Unavailable. HTTP Error 503." when I hit the /test/123 endpoint.
I have already executed the console command to add the port to ACL netsh http add urlacl url=http://+:1234/ user=everyone.
Does anyone know how can I get another port (non 80) to work?
Edit:
I am aware that there is an answer How to run WCF service on a specific port which explains how to bind to another port. However, the accepted answer uses the net.tcp protocol. I would like to use the HTTP protocol.
Is there any way to do it with HTTP protocol? If it cannot be done, then I guess ill have to redesign and swap over to net.tcp protocol.
I am extremely new to .NET development and WCF, so hopefully somebody with experience can point me in the right direction.
As it turns out, the problem had nothing to do with the so-called linked answer.
Prior to running my WCF service in IIS, I was trying to deploy it as a WAS and then Console application. In my process of getting those 2 implementations to work, I had to execute the command netsh http add urlacl url=http://+:1234/ user=everyone so that the port could be accessed.
By sheer luck, i stumbled upon this link:
https://serverfault.com/questions/666976/service-unavailable-if-i-try-to-access-iis-website-via-ip-address-works-fine-vi
Although it didnt have an accepted answer, the comments held the answer. My problem was caused exactly because I executed the netsh command. What happens is that the command causes that ip/port to be reserved, and thus, IIS cannot attach to the ip/port and therefore the Service Unavailable error. I assumed that if the WAS and Console version needed that command to be executed, then the IIS version needed it as well.
As for letting an IIS WCF Service be available on any other port, the process is super simple. Within IIS itself (Execute "inetmgr" in Run to launch), in the default or custom website you created, edit the binding and change the HTTP port to whatever port that you want. After that, its done. You should be able to access your application/website from that port via HTTP.
Eg:
http://localhost:<some port>/<websitename>/MyService.svc/test/123
My WCF Service config was a standard config that allowed for HTTP access.
If you would like to access it from another computer or from the internet, then you will need to configure your router to port forward your selected port (if needed) and ensure that your firewall allows data flow for that port.
Many "thanks" to the downvoters who assume this was some duplicate. Your "help" contributed in finding a solution to the problem.

403 Error For Web Service Call

I am using a 3rd-party tool that runs as a Microsoft Service on a Windows Server 2008 R2 machine. The machine is using a Dell SonicWall firewall. The tool has defined ports that it is listening on of which I have opened one. Using an external web tool that port is listed as open. The service has been installed and shows as running when I run services.msc.
Everything runs great on my local machine. However, when I try to query the service I get a 403 error. The following is what the query URL looks like:
https://{siteUrl}:{portNumber}/scanservice/v2/getstatus?method=jQuery111106758983342442662_1428439579840&_=1428439579841
This is an AJAX GET request coming from an ASP.NET MVC application.
The code attempts to find an open port by querying 3 ports that are the https ports for the service. The first two are ports that I have not opened on the machine. These queries time out which is what I would expect. The last port is the one I have opened on the server. I immediately get a 403 error.
Is there somewhere where I need to expressly allow that service, not just the port?
It is a case where your public IP is not whitelisted on the web service hosting server

HTTP Error 503. The service is unavailable when port 80 is already free

Before you go and suggest it as a duplicate of other IIS HTTP Error 503 questions, I have already tried many solutions available on SO and also on Google but the problem is not resolved. Below are the most popular solutions that I have found:
IIS - HTTP Error 503. The service is unavailable
Solve HTTP Error 503. The service is unavailable in IIS
In my case:
IIS is not working while the port 80 is open and free to use.
As far as I know the error is caused if the application pool is not enabled (started) for the website in IIS.
I have already closed all other applications like Skype, Google Disk etc who can possibly use port 80 and checks if the port is in use or not.
Then I looked into the Application Pools of IIS and found DefaultAppPool status stopped.
After starting the DefaultAppPool I recheck my web and gets the same error.
And now the situation is like, DefaultAppPool status shows started until I don't hit any URL. Whenever I request any URL for my local websites or localhost, the browsers returns me the Service Unavailable error message and the DefaultAppPool status change to stopped automatically.
I have already tried the iisreset command but after resetting IIS the problem is still there.
There is an uncommon cause for 503 error. To fix this, follow these easy steps:
Run this command
netsh http show urlacl
It will list all reserved urls, find the url with relevant port.
Reserved URL : http://+:80/
User: NT SERVICE\Machine
Listen: Yes
Delegate: No
SDDL: D:(A;;GX;;;S-1-5-21-2127521184-1604012920-1887927527-67210)
Then delete the entry with this command (replace the url part with yours):
netsh http delete urlacl http://+:80/
https://blogs.msdn.microsoft.com/webtopics/2010/02/17/a-not-so-common-root-cause-for-503-service-unavailable/
Most probably identity under which you are running your app pool i.e. administrator has wrong password or disabled. Try changing this identity to something like network service or local service or any other valid identity.

"Established connection was aborted by the software in your host machine" (IIS)

I'm trying to configure IIS 7.5 so that it can serve large (400mb) files via HTTP. The client is a C# client using WebClient.DownloadFile() (basically wrapping an HTTP GET request).
However when downloading, I occasionally get the error from the client:
An established connection was aborted by the software in your host machine
Anything I can do in either the client or IIS to prevent this error?
After much digging around, it looks like a dodgy internet connection on my side. All clients on my site disconnect at the same time, but clients on another site stay connected. Unfortunately the internet router that I have here doesnt have any connectivity logs (its a top-of-the-range linksys.. go figure) so it wasnt easy to see what the problem was.

Categories

Resources