简体   繁体   中英

OData WCF connection refused

i've just written a very simple WCF service that exposes a SQL Server database with OData. i can connect to the service, and make requests using "http://localhost:3006" but cannot connect using the ip address, even on the local machine.

i followed these basic steps to set up the WCF service and added the JSONP library from MSDN with no issue: http://www.hanselman.com/blog/CreatingAnODataAPIForStackOverflowIncludingXMLAndJSONIn30Minutes.aspx

i've checked my firewall logs and found nothing suggesting any problems, although the firewall shouldn't even be in question when connecting to my own local IPv4 address. the windows firewall is disabled, and can't be the issue. i saw this line in the web.config:

<!--
<authentication mode="Forms">
  <forms loginUrl="~/Account/Login.aspx" timeout="2880" />
</authentication>
-->

and commented it out, as you can see, but it didn't fix the issue. how can i connect to this debug server from a remote machine?

i was able to solve this problem by doing the following:

perform Windows Update (just do it).
update to Visual Studio 2010 SP1.
get the IIS Express application.
in VS, right-click the project node and click "Use IIS Express..."
in the IIS Express applicationhost.config file you will have a site list in the xml
under the site node that references your project, the binding needs to be changed to this:

<binding protocol="http" bindingInformation=":[preferredport]:" />

where [preferredport] should be the port number you want to use.
at the command line, type this to tell httpsys to listen on all ipv4 addresses:

netsh http add iplisten 0.0.0.0

for ipv6, use this line:

netsh http add iplisten ::

run the project from VS2010 and you should now be able to connect remotely.

this was so much less hassle with Linux rest... seems like something that should have been built in, as devs will obviously want to debug using remote clients...

it may be possible to do this without IIS Express but i'm not sure how you would configure the VS debug server with the appropriate bindings, but this method does the trick without using Fiddler or WebMatrix or any of that other fluffy stuff.

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