1

I'm in the process of doing a server migration, and I've come across an issue when trying to host a WCF application and IIS at the same time using the same IP address and port. (this works perfectly on our other server)

The new server is a Windows 2012 R2 Standard

It is running IIS 8.5.9600.16384

I'm trying to create an exact copy of the previous installation, so that all of our existing clients will continue to work when the switch is flicked (on Tuesday).

The WCF Application runs as a Windows Service.

When I 'start' the web-site, I can access the web-services on there.

If I stop the web-site and start my WCF application, I can then access my WCF's services.

If I then re-start the web-site, the WCF services stop working.

Basically, I can't get both to work at the same time, but this worked fine on the previous server.

Am I missing a setting somewhere?

The addresses I'm listening on are...

https://test.banana.com/WebServices/myservice.asmx

and

https://test.banana.com/WCFService/mywcf.rem

*I'm using a dummy domain name for this example

**Also, the live server has a different domain name, so there's no conflict there.

Rich S
  • 3,248
  • 3
  • 28
  • 49
  • Check out binding information for HTTPS - assuming IIS/WCF supposed to run on 2 different DNS names pointing to the same server... – Alexei Levenkov Jun 20 '15 at 01:49
  • Rich, you can have several applications with same port, since you have different dns for each one. Check if your both applications have valid dns. You said you are migrating your server, in old server both applications was running fine? If so, you just need to fix the dns pointing for the new machine IP, or you need to create a valid dns for both applications. – Ricardo Pontual Jun 20 '15 at 02:18
  • @AlexeiLevenkov , I've edited my question to show the DNS names. How do I check out binding information? – Rich S Jun 20 '15 at 07:25
  • 1
    Please let us know when you find out what the actual setup is... – oɔɯǝɹ Jun 20 '15 at 18:47
  • @oɔɯǝɹ - I've posted my answer - it turns out that it just needed a little tweak, hopefully over the next few days, I'll understand why. – Rich S Jun 21 '15 at 16:18

2 Answers2

1

I don't think a single port can be listened to by multiple processes on the same machine. How would the operating system know where to send the network requests?

That you're using a different DNS doesn't matter, since the DNS filtering / dispatch happens after the HTTPS service has received the GET or POST(or other) request. Before that happens there is no way for the operating system to know to which process the request is meant to go. Using HTTPS complicates this even more, since the requests are encrypted using a certificate that only the service knows, so the request can not be read by the OS.

I would suggest letting IIS host all services on port 443. It can direct traffic for multiple HTTPS sites using the request headers. IIS can read the HTTPS request since you supply the certificate to IIS. You can host a WCF service perfectly well in IIS.

IIS is more reliable for hosting services than a self-hosted service as well.

oɔɯǝɹ
  • 7,219
  • 7
  • 58
  • 69
  • I have this configuration working on the existing server, I just can't get it working on the new server. I can't change the way these services are hosted. The WCF application run as a Windows Service, which has additional functionality (it's not just hosting network requests) – Rich S Jun 20 '15 at 08:06
  • Are you sure that IIS is listening to port 443 on the old machine? You will need to compare the site bindings for all sites on that machine. – oɔɯǝɹ Jun 20 '15 at 08:10
  • Yes, WCF and IIS are both listenting on port 443 (see urls above) – Rich S Jun 20 '15 at 08:11
  • It's not possible to have multiple processes listen on the same ip address / port in a single machine. See http://stackoverflow.com/a/1694148/62662 – oɔɯǝɹ Jun 20 '15 at 08:13
  • It may be possible that the 'old' machine is using multiple ip addresses. – oɔɯǝɹ Jun 20 '15 at 08:25
  • The 'old' machine definitely works with those two addresses I've included in my question, one of them is hosted in IIS, the other in my WCF Windows Service. I'm guessing that something sits 'above' both services (maybe http.sys) and forwards the traffic (encrypted or not) on to the relevant service (IIS or WCF). – Rich S Jun 20 '15 at 15:41
0

It seems that it IS possible after all, and I now have it working.

Basically, the only reason I wasn't able to share the port between IIS and my WCF service was that I was specifying the 'Host Name' in the IIS bindings. As soon as I removed the host name (which I had set to test.banana.com) both of my services started working.

I'm guessing that this is related to the fact that the ip address/port and hostname need to match for port sharing to work properly. As I was specifying the hostname in IIS, and not in WCF maybe it couldn't determine that it was the same endpoint (that might not be the case)

Rich S
  • 3,248
  • 3
  • 28
  • 49