English 中文(简体)
TCP 错误代码 10013 跨域政策错误 NetTcpBinding Service 和 Silverlight 客户端
原标题:TCP error code 10013 Cross Domain Policy Error with netTcpBinding Service and Silverlight Client

如果有人能把我从 跨域政策地狱里救出来的话 一定会很爽的

我有一个双倍的 WCF 服务, 使用 < code> netTcpBining , 客户是 Silverlight 4 应用程序。 当我自己主机服务时, 它会完美运作, 我的 Silverlight 客户可以毫无问题地消费服务。 然而, 当我在 IS 7 中主机时, 问题开始发生时。 当我主机是 IS 时, 我能看到服务在 :

http://localhost/conference/Video meetingService.svc http://localhost/conference/ meeting/Video meetingservice.svc http://locloclochost/conformus/会议/Videoconferences.svc < > > http > http > http > http >

当我加上一个以IIS为主的服务, 并试着把它称为服务时, 我得到一个:

CommunicationException: Could not connect to net.tcp://localhost/Conference/VideoConferenceService.svc. The connection attempt lasted for a time span of 00:00:03.3071892. TCP error code 10013: An attempt was made to access a socket in a way forbidden by its access permissions.. This could be due to attempting to access a service in a cross-domain way while the service is not configured for cross-domain access. You may need to contact the owner of the service to expose a sockets cross-domain policy over HTTP and host the service in the allowed sockets port range 4502-4534.

或者,如果看到实际错误有助于激励那些以前见过的人,这就是它在Reference.cs 中向我扔的东西:

""https://i.sstatic.net/4rh0.png" alt="此处输入图像描述"/"

I have checked out almost every solution suggested regarding solving the cross-domain policy error, and I ve put my clientaccesspolicy.xml in my default website root in IIS, and also in wwwroot. I ve also turned off all my firewalls. I m able to see the policy at http://localhost/clientaccesspolicy.xml and also at http://127.0.0.1/clientaccesspolicy.xml but I still get this error.

以下是我的网络。 IIS 7: 的服务配置 :

<?xml version="1.0" encoding="utf-8"?>
<configuration>

  <runtime>
    <gcServer enabled="true" />
  </runtime>

  <system.web>
    <compilation debug="false" />
  </system.web>
   <system.serviceModel>
     <services>
       <service name="VideoServer.VideoConferenceService">
         <endpoint address="" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IVideoConferenceService" contract="VideoServer.IVideoConferenceService" />
         <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
         <host>
           <baseAddresses>
                <add baseAddress="net.tcp://localhost:4502/VideoServer/" />
           </baseAddresses>
         </host>
       </service>
     </services>

    <bindings>
      <netTcpBinding>
        <binding name="NetTcpBinding_IVideoConferenceService" portSharingEnabled="true" transactionFlow="false" transferMode="Buffered" listenBacklog="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="2147483647" maxReceivedMessageSize="2147483647" closeTimeout="24.20:31:23.6470000" openTimeout="24.20:31:23.6470000" receiveTimeout="24.20:31:23.6470000" sendTimeout="24.20:31:23.6470000">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <reliableSession enabled="false" />
          <security mode="None">
            <message clientCredentialType="None" />
            <transport protectionLevel="None" clientCredentialType="None" />
          </security>
        </binding>
      </netTcpBinding>
    </bindings>

    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="False" />
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
    <system.webServer>
        <directoryBrowse enabled="true" />
    </system.webServer>

</configuration>

这是银灯客户端 SServiceReferences.ClientConfig 文件:

<configuration>
    <system.serviceModel>
        <bindings>
            <customBinding>
                <binding name="NetTcpBinding_IVideoConferenceService">
                    <binaryMessageEncoding />
                    <tcpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
                </binding>
            </customBinding>
        </bindings>
        <client>
            <endpoint address="net.tcp://localhost/Conference/VideoConferenceService.svc"
                binding="customBinding" bindingConfiguration="NetTcpBinding_IVideoConferenceService"
                contract="ServiceReference1.IVideoConferenceService" name="NetTcpBinding_IVideoConferenceService" />
        </client>
    </system.serviceModel>
</configuration>

Has anybody got any suggestions? This annoying error has taken days of my time thus far. Any help would be greatly appreciated.

<强 > EDIT

当我用小提琴手查看在网上会话中检索的文件时, 它显示我的浏览器正在检索客户访问政策文件, 所以我认为错误在别处, WCF 正在向我丢出这个错误。 我还设置了 IE9 来清除它每次关闭的缓存。 请看下面 。

""https://i.sstatic.net/GYKMU.png" alt="此处输入图像描述"/ >

最佳回答

嗯,我只是设法使它起作用。

1. < erroneous 上我在上面张贴的 erroneous ServiceReferences.ClientConfig (我给您服务地址为http://localhost/Conform/VideoconferenceServicice.svc )上的一个服务地址是,但这不是作为终点的一部分产生的,这就是造成TCP错误10016(EndpointNotFoundExpeption )和TCP错误10013时由视觉工作室生成的。

<configuration>
    <system.serviceModel>
        <bindings>
            <customBinding>
                <binding name="NetTcpBinding_IVideoConferenceService">
                    <binaryMessageEncoding />
                    <tcpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
                </binding>
            </customBinding>
        </bindings>
        <client>
            <endpoint address="net.tcp://localhost:4502/Conference/VideoConferenceService.svc"
                binding="customBinding" bindingConfiguration="NetTcpBinding_IVideoConferenceService"
                contract="ServiceReference1.IVideoConferenceService" name="NetTcpBinding_IVideoConferenceService" />
        </client>
    </system.serviceModel>
</configuration>

2. 当我在IIS 7中服务时,我把端口范围 808:/code>作为NetTcp 端口,而我本应把 4502:/code>作为端口范围,例如:

""https://i.sstatic.net/qCwqb.png" alt="此处输入图像描述"/ >

根据我所收集的资料,服务的主机网站应该在80号港口,因为银灯将在localhost:80/ClientAccessPolicy.xml 中查看客户访问政策文件。

顺便说一句,对于遇到同样问题的人来说, 这个 web. config 在IIS中成功工作:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.web>
    <compilation debug="false" />
  </system.web>

   <system.serviceModel>
     <services>
       <service name="VideoServer.VideoConferenceService">
         <endpoint address="" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IVideoConferenceService" contract="VideoServer.IVideoConferenceService" />
         <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
       </service>
     </services>

    <bindings>
      <netTcpBinding>
        <binding name="NetTcpBinding_IVideoConferenceService" portSharingEnabled="false" transactionFlow="false" transferMode="Buffered" listenBacklog="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="2147483647" maxReceivedMessageSize="2147483647" closeTimeout="24.20:31:23.6470000" openTimeout="24.20:31:23.6470000" receiveTimeout="24.20:31:23.6470000" sendTimeout="24.20:31:23.6470000">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <reliableSession enabled="false" />
          <security mode="None">
            <message clientCredentialType="None" />
            <transport protectionLevel="None" clientCredentialType="None" />
          </security>
        </binding>
      </netTcpBinding>
    </bindings>

    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="True" />
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
    <system.webServer>
        <directoryBrowse enabled="true" />
    </system.webServer>
</configuration>

还值得指出的是,您不需要在IIS web.config 中填写任何港口或基地地址。 这将使用 4502 建立服务端点, 我尝试将其改为4503, 4522等, 令人感兴趣的是, 它没有在这些港口起作用, 只有4502个港口。

问题回答

我们遇到一个与原始文章类似的问题。 仅仅为了帮助那些无法用上述解决方案解决问题的人,我们发现服务所在机器上的Windows防火墙堵住了我们试图与Net. tcp连接的港口。 一旦我们允许通过软件防火墙上的港口,我们的服务就开始按预期运作。

也许值得检查一下你可能设置的任何硬件防火墙 以及允许我所相信的 45024530的射程





相关问题
Session Management with Windows Authentication

In an ASP.NET web app, using Integrated Windows Authentication, is the session tied to the windows identity? In other words, if I login (using IWA) to the app, and the app stores some "stuff" in my ...

Using Elmah with Cassini

Does anyone know if I can use Elmah with Visual Studio build-in web server(aka Cassini)? I get it working easily on IIS, but using same configuration, it doesn t work with Cassini. When I requested ...

Setting hostname in IIS, include www?

I want to set the hostname for a website I m adding in IIS 7, however do I include the www in the hostname or not? because I want both www.mysite.com and mysite.com both to point to mysite on the ...

inetpub versus any other folder

I ve run websites out of inetpub, as well as from folders just residing on the C: drive. I wonder, are there any definitive advantages to running websites out of inetputwwwroot?

IIS 6.0 hangs when serving a web-service

I am having issues with one of our web-services. It works fine on my development machine (win XP) whether I host it as a separate application or using cassini from Visual studio. Once I deploy on the ...