0

I have a remote .Net web service that I have added as a web reference to my project via its WSDL. When I try to invoke a method on it I get the following exception:

A socket operation was attempted to an unreachable network 176.31.222.123:443
   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)

The address it's trying to connect to is one of my own servers, and not only can I quite happily reach that IP address from my machine - other parts of the code that are also connecting to the same server work absolutely fine. It's only when using the web reference that it falls over.

Even weirder is that it doesn't happen on every machine, even between different machines on the same network give different results.

I'm almost certain something very daft is going on that will make me face palm, but does anyone have any clue about what on earth is going on?

PhonicUK
  • 13,486
  • 4
  • 43
  • 62
  • Is this an ASMX client or a WCF client ("Add Service Reference")? Have you looked at the network traffic with Fiddler or something? – John Saunders Dec 08 '12 at 23:19
  • Can you telnet to port 443 on the relevant server from the host you're having trouble connecting from? – Will A Dec 09 '12 at 00:34
  • @WillA, I can get to the address in a web browser on the same machine quite happily. (It's HTTPS of course) – PhonicUK Dec 09 '12 at 00:52
  • @JohnSaunders it's ASMX (.Net Web Services instead of WCF). Wireshark showed nothing, it didn't even try to talk to it. – PhonicUK Dec 09 '12 at 00:53
  • Is there a proxy between your machine and the server - or a software firewall on your machine? – Will A Dec 09 '12 at 00:54
  • @WillA, No on both counts. And my code can still reach that same host in other request it makes, just not when using the ASMX. – PhonicUK Dec 09 '12 at 00:56
  • FYI, WCF _is_ ".NET web services". ASMX is a legacy technology that should not be used for new development unless you have no choice at all. – John Saunders Dec 09 '12 at 00:57
  • Might be handy to include the relevant sections of your app.config or web.config. – Will A Dec 09 '12 at 00:58
  • @JohnSaunders Noted. ASMX is still being used because there doesn't seem to be a way of forcing the outbound requests from the client to be made via a specific interface when using WCF (instead of just any available) which is required in this case. – PhonicUK Dec 09 '12 at 00:59
  • WCF is _far_ more flexible than ASMX in terms of networking. If you ask "how do I chose the network interface for outgoing calls in WCF" on [so], I'm sure you'll have five answers within a day or so. Though you should search on that first, and you may find the answer is already here. – John Saunders Dec 09 '12 at 01:01
  • @JohnSaunders, Barked up that tree many a time. It was confirmed as not doable by a MVP - http://stackoverflow.com/questions/3577248/how-to-bind-a-wcf-http-client-to-a-specific-outbound-ipaddress-before-making-the – PhonicUK Dec 09 '12 at 01:03
  • 1
    @PhonicUK: some unnamed MVP, two or more years ago. I'm pretty sure it can be done with WCF, and, if you need the reassurance, _I'm_ an MVP as well! If you can take over the entire transport with WCF (and you can), then surely you can have the transport choose the network interface to use. – John Saunders Dec 09 '12 at 05:51

0 Answers0