WCF hosting issue on IIS 7 server with multiple IPs - wcf

This service is hosted on Win2k8 R2 with wshttp binding and all security options are disabled specifically. If I assign "All unassigned IP" in binding it is working well. However if I assign a specific IP, it fails during service reference ( wcftestclient Add service option) with message like Report from 'DISCO Document' is 'There was an error downloading 'http://abcd.xxxxx.net/Management/ManagementService.svc?disco'.'.
- The request failed with HTTP status 404: Not Found.
I see that it picks the machine name though we started with http://10.10.1.1/Milestone/Milestone.svc. I checked with ping that abcd is not mapping to 10.10.1.1 but another Ip of same machine 10.10.1.2.
How can I force WCF to use IP instead of machine name? Or is there any other way to address the scenario.

If you enter http://10.10.1.1/Milestone/Milestone.svc into a web browser, instead of WCFTestClient, does that work? Switching from IP to the machine name may just be something that WCFTestClient does, but that shouldn't effect your eventual "real" clients, since they can use IP or server name.
I host my WCF services on Win 2k8 in IIS on a machine that has >1 IP, and it works fine, but in my case I bind WCF to only 1 IP address. It has been a while since I set that up, but I thought in the WCF configuration, and endpoint had to be bound to only 1 IP address. That IP should match what IIS is set to accept also. Alternatively, I think multiple endpoints can be created, one for each IP.

Related

net.tcp wcf service (windows service hosted) in domain server and client outside of domain

I have a wcf service (with net.tcp binding) hosted at windows service and a wpf client. when I run the service in a server outside the company's domain it works excellent, the problem is when I host the service in a server inside the company's domain, and try to run the wpf app in a client outside of the company domain.
I'm getting the same error, "The Socket connection was aborted..."
I try with Security Mode None, Transport and the same result.
My question is, what is the correct way to do that? I mean host the wcf net TCP service in a domain server and call it from a client outside of domain?
Thanks a lot!
I change the binding from net.tcp to wshttp and the service works fine!
Server with the corporate domain and client without corporate domain
The thing is I need the make this work with net.tcp
Neither a Windows Domain nor DNS have anything to do with WCF/TCP if you don't explicitly make it so.
Assuming the address you gave actually leads to the PC you host your service on (so no local IP addresses) and nothing in between (like a firewall) blocks the connection, it should work.
The correct way is to make sure client and server can talk to each other. If it's different networks, you will need NAT and if one is a corporate network I'd be very surprised to see no firewall that you need to configure.
As a first step, try to ping your target machine from your client machine.

iis 8 not accepting ip address as hostname

We are trying to specify IP address instead of hostname(eg: www.abc.com) for WCF service hosted in IIS v8.0 on windows server 2012
This gives error saying special characters not allowed. Is this not allowed?
But it works fine when we specify IP address as host name in our local systems which runs IIS v7.5.
A hostname is not an IP address, therefore you can't specify it in the site bindings as a host name.
If you are trying to access a service on your local IIS machine, simply having the site binding present is enough, but you may want to bind it to a specific IP address (the IP address dropdown), or if you leave it as "All Unassigned" then the application will be available on all IPs registered with the server, on your chosen port.
If you are trying to access an app on another machine from yours, you can either get a DNS value added by your network admin, or change your HOSTS file (C:\windows\system32\drivers\etc\HOSTS) and add in your own alias:
54.XXX.XXX.XXX myalias
Which means you should then be able to access http://myalias:8092/ from your browser.
Update The validation message is apparently by design:
http://blogs.msdn.com/b/dasane/archive/2013/10/16/adding-ip-address-like-host-head-in-iis-8-shows-ui-validation-error-this-worked-fine-in-iis-7-5-and-earlier.aspx
Reading that article, I can now understand why you may want to use an IP address as a host-header, as it effectively allows you to route external IP address calls to your local machine without requirement of DNS changes. For what you need though, if the IP address is bound to an NIC on your local machine, just leave it blank as it will resolve locally anyway.
Check what you provided in Hosts file (C:\Windows\system32\drivers\etc folder) in your local machine
For the above case you need to provide the hostname not ip address

Silverlight Cross Domain exception when using IP Address

I have a strange issue where browsing to my Silverlight 5 website using the host name works perfectly fine but when using the IP address instead it throws this exception: http://iforce.co.nz/i/1ohkll5v.32o.png
I have implemented the clientaccesspolicy return stream in a REST service on my self hosted WCF web service (similar to Cross Domain Exception with WcfSvcHost), and it works perfectly fine when using the hostname. However if I debug that method it never actually gets called in the scenario with the IP address.
Is there some limitation in Silverlight that does not allow you to use the IP address with WCF? I seem to remember that this was working before some time ago.
Another reason of this error is that Silverlight prevents cross-zone acccess, too. Therefore, in the clinet browser, you need to add both addresses (the one with hostname and the one with IP address) to the same Security Zone (either Local Intranet or Trusted Sites) in Internet Explorer.
Although this is an old question—and it will not help you, it might help others.
I had the same issue and lost hours trying to find the answer. The problem for me—in the end—was that I was referencing the WCF service using the machine name. Because of this—Silverlight thought I was referring to a local machine—so Silverlight doesn't even bother making a client policy request.
So just reference the service using an IP address instead of the machine name. Even if that IP address is local. Then check with Fiddler and notice that the Silverlight client will now make a policy request before the first service call.

WCF: how to consume a self host service from internet?

I have a self host service in a WPF application and a client. It works fine if the client and the service are in the same LAN, so I can send messages from client to the service.
However, I would like to know how I can consume the service from internet.
I open the TCP ports for the listing port and the mex in my router in the NAT section and I have disabled my firewall of windows (I am working in a virtual windows xp).
I am trying to use net.tcp binding, is my first option, but also I am trying with wsHttpBinding and the problem is the same, I can send message in the LAN but I can't from internet.
Perhaps it's because I don't know how to configure the address in the service or in the client, or something like that.
Thanks you very much.
Daimroc.
EDIT1: if I use the www.canyouseeme.org the can access to my service. If I stop my service then i get an error. So it looks like that the service is visible. Then why can't send messages from the client?
Since you're on a LAN, it is very likely that the machine that is hosting the WCF service is not assigned an IP address accessible from the Internet. For example, if the machine has an IP address starting with 10... or 172... or 192... then that is an internally assigned IP address.
Your machine must be set up to use an IP address assigned by a registrar and optionally, assigned a domain name (e.g. canyouseeme.org) so the Internet DNS servers can translate it to the assigned IP address.

Access WCF in Azure Using Mapped Domain Name

I have a WCF service in Azure. I can reference its IP address and successfully hit it with a browser or with WcfTestclient.exe. I've gone into GoDaddy and mapped svc.mydomain.com to my IP/port and now I can't hit with a browser, but not with WcfTestClient.exe. The error is "Error: Cannot obtain Metadata from http://svc.mydomain.com/Service1.svc?wsdl... Metadata contains a reference that cannot be resolved: 'http://svc.mydomain.com/Service1.svc?wsdl'. The remote server returned an unexpected response: (408) Request. The remote server returned an error: (408) Request Timeout.HTTP GET Error URI: http://svc.mydomain.com/Service1.svc?wsdl The HTML document does not contain Web service discovery information."
When I hit it with the browser it comes back with the stock html showing that it found the service, but it refers to it by its IP, so I wonder if it's a config file change that I need to make.
Is it best practice to nickname my service with a CNAME (i.e. svc.mydomain.com) and thus reference my services with like: http://svc.mydomain.com/MyService.svc?
You shouldn't rely on the IP address for a Windows Azure service. The IP addresses can and almost certainly will change (for instance, if you deploy from within Visual Studio, it tends to result in a different IP address being allocated).
You service already has a DNS name: deployment name.cloudapp.net
The Windows Azure Management Portal will show you the DNS name.
If you want to address the service using a different DNS name, use a CNAME to create a DNS alias.