Azure Cloud Emulator remaps ports - visual-studio

I have a solution that contains a website and a Windows Azure Cloud Service Project. Here is the ServiceDefinition.csdef:
...
<WebRole name="FrontEndWeb" vmsize="Small">
<Sites>
<Site name="Web">
<Bindings>
<Binding name="Endpoint1" endpointName="Endpoint1" />
</Bindings>
</Site>
</Sites>
<Endpoints>
<InputEndpoint name="Endpoint1" protocol="http" port="2996" />
</Endpoints>
...
</WebRole>
...
I have the web-debug settings set to: Visual Studio Development Server & Auto Assign Ports
When I run the Windows Azure Cloud Service Project, I get the following message in my General Output log: Windows Azure Tools: Warning: Remapping private port 2996 to 2997 in role 'FrontEndWeb' to avoid conflict during emulation.
It is imperative that the site run on port 2996 due to a host validation requirement.
Things I've tried:
Manually specifying the port for the web for Visual Studio Development Server
Using IIS Express with the exact port I'm aiming for
Things I do NOT have:
IIS installed on my computer
Why is the Azure Cloud Emulator remapping the ports, and what can I do to prevent it from doing that?

It might be possible that some other application is already running on 2996. Try to run nestat command from dos prompt and see which applications are running on which port?

Without the intention of "digging old graves" but if it's for others' benefit. I found myself in the same situation and managed to get around it without "feeling gross".
I noticed that when MSBuild is applying the transformations to the ServiceDefinition.csdef file, this file was not really just copied from the solution folder to the output folder. Instead it was being parsed and re-emitted. This transformation was however not without subtle side effects. Notice this difference:
<!-- the .csdef file in the solution -->
<InputEndpoint name="Endpoint1" protocol="http" port="8080" />
<!-- the .csdef file after MSBuild -->
<InputEndpoint name="Endpoint1" protocol="http" port="8080" localport="8080" />
Notice the extra localport attribute. As you know web roles have an internal and a public endpoint (one in front, one after the load balancer) and these ports seem to be managed by these attributes. By default only the port attribute is generated when creating a new project - thus the confusion.
When deploying the package to the emulator, CSPack needs to avoid using the same port for these two endpoints, thus re-routing the internal one.
The simple fix is to manually add the localport attribute in the .csdef file and specify a port value different from the public (or any other) one.

Have the same problem. But I don't have IIS installed, don't have Web Matrix and don't have anything listening the port 80 before.
So when I start debugging, I see "remapping from port 80 to 81". However emulator starts my webrole listening on port 80. That wouldn't be problem, but in my code I have the following code for constructing links:
int port = HttpContext.Current.Request.Url.Port;
if (port != 80 && port != 443)
{
uri.Append(":");
uri.Append(port.ToString());
}
So when I start debugging and open my site in browser entering http:// localhost, strangely I have all my links pointing to the http://localhost:81.
Again, webrole endpoint is on port 80.
After the debugging start I see that DevFC listens on port 80, but System process (image path points to the ntoskrnl) listens port 81.
What's happening?

The Azure Compute Emulator simulates the entire Azure fabric, including the load balancer and multiple instances. Because of this, forcing specific IPs onto the Emulator is tricky business, as the Emulator will remap the VIP (virtual IP address) to simulate the Azure platform.
This article http://blogs.staykov.net/2013/05/windows-azure-basicscompute-emulator.html explains in detail the emulator environment.
It sounds like you need that port to satisfy an external requirement; have you considered running your app in debug mode outside the emulator? You can launch it in a standard IIS Express instance and control the endpoints using the IIS Express .config files, and then deploy normally to Azure for production.

In my case i had my web application with the property SSL Enabled set to "True" and i didn't have a endpoint in my Web Role Cloud settings for Https.
Open your Web Role settings and in the left hand side menu click on the third menu called Endpoints and add an endpoint for Https. Now click on Configuration tab and you will see a section "Startup action". Uncheck HTTP endpoint and check HTTPS endpoint.

I struggled with this issue for some time and annoyingly the solution was to restart my computer.

Related

Why aren't my networked computers able to access localhost from VS2017?

Coming from XAMPP, using the Apache server, I am used to just test my websites in a networked computer by simply typing IPaddress:PortNumber on the address bar of the desired networked computer.
Then while developing with VS2017, I found out that it is not possible by default. While it works fine in the localhost, any networked computer is unable to access the website. What do I need to access to change the settings so that I can expose it to port 8012 rather than 127.0.0.1:8012 ?
I assume that's the problem here.
I was able to solve this problem by changing the binding values in applicationhost.config
VS2015 onwards, it can be found inside the individual project folder %ProjectFolder%/.vs/config/
In pre-2015 VS, its available in %USER%/Documents/IISExpress/config/
If you are familar with XAMPP, the setting is similar to %XAMPP%/apache/conf/httpd.conf
The difference is that, instead of setting a Listen port number, you have to properly bind the port in IISExpress
By default, port is bound to localhost for the host computer. Say, port 3940 is bound as *:3940:locahost, which makes it only available to the computer running VS.
To make this available to networked computers, you need to change this section as follows:
Change this:
<bindings>
<binding protocol="http" bindingInformation="*:3940:localhost" />
</bindings>
to:
<bindings>
<binding protocol="http" bindingInformation="*:3940:*" />
</bindings>
Note: In some cases, bindingInformation="*:3940:" may be used instead of bindingInformation="*:3940:*"
If after all this, it still does not work, then it may be a firewall issue as #Mukesh pointed out in his comment.
Firewall issues can be quickly found out by simply pinging the target device.
If the ping is successful but the port is not allowed, then open the firewall in advanced mode
Open RUN (Windows + R)
Type firewall.cpl
Click on Advanced Settings
Click on Inbound Rules
Create New Rule
Add your desired port to the rule
Port > Specific local ports: 3940 > Allow the connection > Check all (Domain, Private, Public) > Give a name to your rule: ExampleRule > Finish
You can replace 3940 with your desired port number or port range. It is also possible to select all possible ports.
optional: Although nothing really needs to be done in the client computer, you may need to configure your firewall inbound rule to accept all Inbound connections
If it is not a firewall issue, it can be something else entirely. Maybe you're getting a 400 Error page, or a 503 Error. The following SO questions helped me a lot to tackle those problems (although I had to revert the ACL allowance later). I hope this is useful to someone in the future
IIS Express Configuration
Change binding, ACL and Port forwarding
HTTP 400 Bad Request Error
Solution to this ^ is here
503 Service Unavailable Error
Sometimes this is solved by simply creating binding entries in applicationhost.config
Other times, its the duplicate-binding problem. And you need to remove a binding entry during those times. If you are editing applicationhost.config inside the project folder, then it is okay to keep only one site and binding information.
for my particular case, I had to revert this operation netsh http add urlacl url=http://192.168.10.3:3940/ user=everyone with this netsh http delete urlacl url=http://192.168.10.3:3940/ because I kept getting 502 Bad Gateway error when I tried tunneling.
Things to remember:
Please remember to properly restart IISExpress after each change. Normally VS does this by itself. Just double check for any running instances.
Also, always run VS in administrative mode. This usually clears many problems and also allows all sub-processes, such as IISExpress to startup in elevated privilege mode to avoid permission errors.

How do I allow other (mac) machines to access an IIS7 hosted MVC3 application on my (win7)machine?

I am trying to make my MVC application accessible on other computers, specifically mac machines. This is my first time to run a site on IIS7 because I got used to the older version of IIS on winXP at work. While on this computer I just usually use VS2010's development server.
I am using windows7 (64bit) and I want to access this site on a mac / other machines.
My site bindings setup are as follows:
Type: http
IP address: All Unassigned
Port: 80
Host name: www.thisisatest.com
ON MY MACHINE: I can access www.thisisatest.com but not COMPUTERNAME/www.thisisatest.com or IPADDRESS/www.thisisatest.com which I think supposedly should work because I've done this many times in our office on winXP.
But I can access the IIS7 page with COMPUTERNAME/ or IPADDRESS/
ON ANOTHER MACHINE (MAC): I'm getting the Server Not Responding error when I try to access IPADDRESS/
My firewall is already turned off and I've already added an Inbound Rule on my firewall to open all ports.
Questions:
1.Why can't I access the site using COMPUTERNAME/www.thisisatest.com or IPADDRESS/www.thisisatest.com even on my own machine? This is weird because it is my own machine where my app is hosted.
2.What should I do to allow remote access? Does it matter if it's a mac machine that I'm using to access the site?
Any ideas?
For that to happen your app should be set up in a folder called www.thisisatest.com. Setting that host name in the app's properties does not mean you access it through http://IPADDRESS/www.thisisatest.com. It means IIS will only route those requests to the app if the address used by the client is of the form http://www.thisisatest.com/<querystring>. Any other request will not be fulfilled. Try to remove that setting, this should allow you to access the app via http://IPADDRESS/ or http://MACHINENAME (on Windows). On a Mac only the IP variant would normally work (unless the IIS machine is resovlable through a DNS).
Unless the port on which the website runs is blocked, the app should be accessible via IP. Of course there are other ways of blocking certain client IPs etc but if you didn't alter any default settings then it should work.
I realize this is not an answer to your question about IIS. I run my development sites on IIS Express, and needed to access a site running on IIS Express from my macbook pro and ipad. If you decide to switch from IIS to IIS Express, you can use this approach to access a site running in IIS Express from other machines on your network (including phones and tablets running over your WiFi DHCP).
First, follow Scott Hanselman's Ninja guide to running your site on ports 80/443 over IIS Express.
Then, find the IP of your VS win machine on your network. Today mine is 192.168.1.113.
Next, open MyDocuments/IISExpress/config/applicationhost.config. In Hanselman's article, you had to set <binding> sections here. Just add a new one for your IP. Here is what it might look like:
<bindings>
<binding protocol="http" bindingInformation="*:1976:localhost" />
<binding protocol="https" bindingInformation="*:44376:localhost" />
<binding protocol="http" bindingInformation="*:80:HANSELMAN-W500" />
<binding protocol="https" bindingInformation="*:443:HANSELMAN-W500" />
<binding protocol="http" bindingInformation="*:80:192.168.1.113" />
<binding protocol="https" bindingInformation="*:443:192.168.1.113" />
</bindings>
After opening your firewall, start VS as an administrator, and run your site. If you can access it over http://localhost:1976, and http://HANSELMAN-W500 (or your computer name), you should then be able to access it from the mac or tablet using this URL:
http://192.168.1.113/
or, if you also set up SSL on port 443,
https://192.168.1.113/
You can also get this to work by running VS as a normal user instead of as an administrator. For that, you will have to run commands like the following:
netsh http add urlacl url=http://192.168.1.113:80/ user=everyone
netsh http add urlacl url=https://192.168.1.113:443/ user=everyone
... again, these commands (as well as how to undo them) are available on the Ninja article. After running them, IIS Express should start up from VS without having to run it as an administrator.

Android Emulator loopback to IIS Express does not work, but does work with Cassini

I am attempting to post data from an Android application running in the Android Emulator on my local machine to a web application running under IIS Express also running on my local machine. Unfortunately, when I post to 10.0.2.2 from the emulator I receive a Host Not Found error message.
If I configure the web application to run under ASP.NET Dev Server (Cassini) instead of IIS Express the Android application is able to post with no problems. What configuration am I missing for IIS Express that is preventing it from working with a loopback from the Android emulator?
Grant yourself permission to bind to network adapters other than localhost, and configure IIS express to bind to all adapters.
IIS Express will then accept connections from the Android emulator via 10.0.2.2. If you add a rule to the firewall, you can also expose IIS Express to your network, which decreases security but is useful for testing physical devices.
Step details: (they assume a port number of 5555 - use your actual port instead)
Run this from a command prompt as Administrator:
netsh http add urlacl url=http://*:5555/ user="NT AUTHORITY\INTERACTIVE"
In %USERPROFILE%\Documents\IISExpress\config\applicationhost.config, replace your site's localhost binding with bindingInformation="*:5555:*". The result should look like this:
<site name="..." id="...">
<!-- application settings omitted for brevity -->
<bindings>
<binding protocol="http" bindingInformation="*:5555:*" />
</bindings>
</site>
Add following line to IIs config file (ex c:\Users[YourName]\Documents\IISExpress\config\applicationhost.config ) Change the port 8085 if required..
<binding protocol="http" bindingInformation="*:8085:127.0.0.1" />
so your config file will end-up with something like this
<bindings>
<binding protocol="http" bindingInformation="*:4396:localhost" /> // the existing one
<binding protocol="http" bindingInformation="*:8085:127.0.0.1" /> // new line
</bindings>
now you can call your web service from remote by calling to port 8085
ex from android emu.
new HttpPost("http://10.0.2.2:8085");
By default, IIS Express only accepts connections from localhost. To enable connections from remote devices (and the emulator counts as such), use the instructions from here.
In short:
netsh http add urlacl url=http://[machinename]:[port]/ user=everyone
netsh http delete urlacl url=http://[machinename]:[port]/
Replace [machinename] and [port] with your computer name (or non-local IP) and port IIS Express runs on.
Also, see this question and this one.
Here is my solution:
I am using Visual Studio Express 2013 for Web and my RESTful web service is running on IIS express.
When I tried to access my web service using an Android emulator in the same machine it gave me this invalid hostname error. As suggested by above answers I did add new bindings to my applicationhost.config file but still it didn't work. At last, I was able to fix this issue by running Visual Studio "as administrator".
You need to add a new binding for your PC name or change a binding to *:<port>:* or :<port>: and then allow that port using Windows Firewall with Advanced Security.
File to look into is <solution folder>\.vs\<project name>\config\applicationhost.config around line 167

IISExpress returns a 503 error from remote machines

I'm attempting to test a website I have running in a local IISExpress instance with some other machines / devices on my local network. I am running Win7 Pro.
When I first attempt to browse to my machine from another machine on my local network segment, I get a 400 error: Hostname is invalid.
I understand that I need to grant remote access to the ACL with a command on the elevated command prompt like:
netsh http add urlacl url=http://mymachinename:50333/ user=everyone
Now I get a 503 service is unavailable error.
Windows Firewall is currently shut off, and I am able to browse my local IISExpress instance with the address http://localhost:50333
What is the final piece to this configuration puzzle?
It looks like you are missing a binding information entry in applicationhost.config file.
Open your applicationhost.config file. Possible locations are:
%userprofile%\Documents\IISExpress\config\applicationhost.config
$(solutionDir)\.vs\config\applicationhost.config (VS2015)
Failing that, inspect the output from iisexpress.exe to be sure.
Locate your WebSite entry and add following binding with your machine name.
<binding protocol="http" bindingInformation=":50333:your-machine-name" />
Restart IIS Express
There was only 1 thing that worked for me.
using *:portnumber:* was no good. Yes, after doing that and making sure the Windows Firewall was open, I could connect to the port, but I still got the "503" error.
I tested a few things locally, and discovered that only http://localhost worked. Using the real IP address (not 127.0.0.1, but, for instance, 192.168.1.50), still returned a 503 even on the local machine. I tried using the real host name in the bindings, but IIS Express refused to start. This may actually have something to do with how the host name was being resolved. I didn't explore that further.
Finally, I ended up using this configuration:
<binding protocol="http" bindingInformation="*:53351:localhost" />
<binding protocol="http" bindingInformation="192.168.1.50:53351:*" />
In that way, I was able to connect from a remote machine using http://192.168.1.50:53351.
After wasting more than 3h on such a full subject I decided to share my setup with you.
My configuration is Visual Express 2012 for Web update 4 on windows 8. This was my first come back to MS VS since studies (at least 8 years) and now I'm sure that linux rules. On django this kind of setup took me 10min of searching documentation.
turn off firewall for testing
netsh advfirewall set allprofiles state off
setup bindings in my case local address is localIP=192.168.1.102 (because links can not contain nonnumeric domain, use it below instead of mylocaldomain.com, see stackoverflow policy)
in Documents\IISExpress\config\applicationhost.config
<bindings>
<binding protocol="http" bindingInformation="*:53351:mylocaldomain.com" />
<binding protocol="http" bindingInformation="*:53351:localhost" />
</bindings>
add autorun for ISS Express start service automatically
<site name="NeuronCharts" id="2" serverAutoStart="true">
Add some weird rules to http server (I still do not know if this is nesseary)
netsh http add urlacl url=http://mylocaldomain.com:53351/ user=everyone
run IISExpress manually not from VS IDE
you will see that ISSExpress is registering bindings
run browser http://mylocaldomain.com:53351
if it is working then we can add firewall rule
add firewall rule
netsh advfirewall firewall add rule name="IISExpressWeb" dir=in protocol=tcp localport=53351 remoteip=any action=allow
set remoteip to any if you want to access you server from outside world if you want to access for local network use localsubnet
start firewall
netsh advfirewall set allprofiles state on
check again if everything is working on local and public ip
Wish you luck
Rafal
Found the problem had to do with a bad urlacl mapping. To figure this out:
netsh http show urlacl
and look for things like http://+:80/ or the port you are binding to.
Then use
netsh http delete url=<the url from the list>
This fixed the problem for me.
Nothing worked for me. Finally I found iisexpress-proxy
See my answer https://stackoverflow.com/a/33623399/631527
Another solution is ngrok
What helped me, was right clicking the 'IISExpress' icon, 'Show All applications'. Then selecting the website and I saw which aplicationhost.config it uses, and the the correction went perfectly.
The problem is updating the applicationhost.config file inside the web folder instead of the solution's. The solution config file is the one to change
Regarding Anthony Rizzolo's answer: in Windows 8.1, I had to type like this:
netsh http delete urlacl url=<the url from the list>
For example:
netsh http delete urlacl url=http://+:8689/
After solution of #vikomall don't forget to start VS as adminisrator.
This fix it for me.
None of the answers above worked for me.
I have had two entries in netsh for the same service
netsh http show urlacl
One using a strong wildcard, the other one using a weak wildcard.
Removing the one with the weak wildcard did the job.
More about the strong and weak wildcard in the context of netsh
When the host element of a UrlPrefix consists of a single plus sign
(+), the UrlPrefix matches all possible host names in the context of
its scheme, port and relativeURI elements, and falls into the strong
wildcard category.
When an asterisk (*) appears as the host element, then the UrlPrefix
falls into the weak wildcard category. This kind of UrlPrefix matches
any host name associated with the specified scheme, port and
relativeURI that has not already been matched by a strong-wildcard,
explicit, or IP-bound weak-wildcard UrlPrefix. This host specification
can be used as a default catch-all in some circumstances, or can be
used to specify a large section of URL namespace without having to use
many UrlPrefixes.
https://learn.microsoft.com/en-gb/windows/desktop/Http/urlprefix-strings

Accessing TEAMCITY from a remote machine

I am having trouble browsing to my team city(JetBrains) from a remote machine. I have followed the install directions and the install went smoothly. I can browse the to application locally on the server, no problem at all. I changed the default server url in the config file to be http://my servername . I can browse to http://my server name and the application shows up no problem locally. The application is alos installed on the default 80 port of the server with no other web server installed.
If I browse to http://my servername from my laptop on the same domian nothing happens. When I run diagnostics it seems to pick up the webserve but it fails to respond.
As a test I uninstalled the app and installed IIS to see if I could browse to the default IIS page remotely. This worked no problems at all. I uninstalled IIS, ensured nothing was hogging port 80 on the server. Reinstalled the applicaiton, configured it exactly the same, still nothing. The application works fine locally, but I get nothing remotely.
I was just wondering if anybody knows anything else I can try? or is there a setting in tomcat I need to tweak?
I just updated TeamCity from 7.0 to 7.1, and now I have the exact same issue.
However, what turned out to be the cause had nothing to do w/ the TeamCity upgrade. It turns out our system administrators had setup a policy update to block all incoming connections other than port 80. When I started my upgrade, I noticed the server wanted to do some system updates. So I let that go first.
I suspect that had I tried to access the TeamCity server after the system update, I'd have realized I could no longer access the website remotely.
But since I only noticed it after the TeamCity update, I assumed it to be the culprit and wasted a bunch of time on that red herring.
The solution for me was to
Open Windows Firewall on the server
Click on the root level option in the left-hand pane
Make sure under each of the profile sections, that inbound connections are allowed.
(#3) was my problem.
Hope this helps someone else out in the future...
Verify that the server is running on port which is not blocked by the firewall. Change the port if necessary.
Tomcat also supports binding to specific IP addresses, in case your machine has multiple IPs, you can configure which one to use in server.xml, like:
<Connector port="80" address="10.10.10.10" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
Where 10.10.10.10 is the IP of the server which can be accessed from the remote machine.
Check the server logs to ensure that it's started on the correct IP/port and is accepting connections.
I just faced the same issue when evaluating TeamCity v10.0.
I solved it by changing the 'Server URL' value with the name of my computer that can be used from remote computer.
As they say, "make sure the server is accessible by the URL specified".
To reach this setting:
- Login to TeamCity interface then
- Click on the 'Administration' link
This is well explained in the TeamCity support page:
https://confluence.jetbrains.com/display/TCD10/Configuring+Server+URL
The problem is that TeamCity's default server.xml has localhost as the host name. You need to add an alias for it answer that name as well, as described here:
http://tomcat.apache.org/tomcat-4.0-doc/config/host.html#Host%20Name%20Aliases
Ryan

Resources