简体   繁体   中英

Conflict when running IIS and WCF application listening on the same port (443)

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.

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.

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM