积极答复者
请教:Silverlight 4 net.tcp 访问 wcf duplex通讯问题

问题
-
我按照官方帮助文档写了个例子,实验Silverlight 4 net.tcp 访问 wcf duplex通讯,
可就是不能连接成功,报告错误:
Could not connect to net.tcp://localhost:4502/DuplexService/Service1.svc. The connection attempt lasted for a time span of 00:00:03.9450055. TCP error code 10061: 无法建立连接,因为目标计算机主动拒绝连接。. 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.
有时出现以下错误
The message could not be dispatched because the service at the endpoint address 'net.tcp://localhost:4502/DuplexService/Service1.svc' is unavailable for the protocol of the address.
我的配置是这样的:
系统windows7 iis7.5 ,已经开启wcf http激活及wcf 非http激活
已关闭了防火墙.
网站添加了绑定:net.tcp 4502:* 已启用了协议:http,net.tcp
建立了虚拟目录,
且在网站root(wwwroot)下及虚拟目录下放置了crossdomain.xml,clientaccesspolicy.xml 两个文件(可能只需要在root下放置crossdomain.xml就可以了)文件内容:
<?xml version="1.0" encoding ="utf-8"?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from>
<domain uri="*" />
</allow-from>
<grant-to>
<socket-resource port="4502" protocol="tcp" />
</grant-to>
</policy>
</cross-domain-access>
</access-policy>我的工程代码如下:工程代码下载
需要用visual studio 10 打开
尝试了好多方法,参考了好多网上现有的资料,可就是不能成功,请高手指点
可以直接回复,也可以给我回复邮件 ewqs2008-08@yahoo.cn
谢谢
答案
-
你好,
我下载了你的例子,在code上没有错误。
可以正常的work.
从你的错误信息看一般可能是由于,你的防火墙吧这个端口block掉了。
建议你使用Fiddler来观察你的request是否成功获得clientaccesspolicy.xml,以及它是从哪个位置去request这个文件的。
你需要吧这个文件放在和你的virtual directory同级文件夹
比如你的Service是这样访问的 net.tcp://xxxxxx:4502/DuplexService/Service1.svc
但是SL会这样去request你的cross domain file : http://xxxxx/clientaccesspolicy.xml
- 已标记为答案 Min-Hong Tang - MSFT 2010年5月13日 4:34
全部回复
-
你好,请试试http://localhost/clientaccesspolicy.xml
http://localhost/crossdomain.xml
这两个地址是否可以打开。
BLOG:http://beniao.cnblogs.com MSN:beniao@live.cn -
你好,请试试http://localhost/clientaccesspolicy.xml
http://localhost/crossdomain.xml
这两个地址是否可以打开。
BLOG:http://beniao.cnblogs.com MSN:beniao@live.cn
这个没有问题,可以打开 -
这几点你可认真思考下:
1,无法建立连接,因为目标计算机主动拒绝连接
2,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
---------------------
解决方法(参考)
1,telnet下端口是否开启。
2,涉及到了哪些跨域的访问?是不是赋予了权限?
3,GookLuck~^_^
我来了~telnet 端口是通的
涉及到了哪些跨域的访问?是不是赋予了权限?具体是什么权限,我的clientaccesspolicy.xml文件内容就在上面,有什么问题吗?
-
你好,
我下载了你的例子,在code上没有错误。
可以正常的work.
从你的错误信息看一般可能是由于,你的防火墙吧这个端口block掉了。
建议你使用Fiddler来观察你的request是否成功获得clientaccesspolicy.xml,以及它是从哪个位置去request这个文件的。
你需要吧这个文件放在和你的virtual directory同级文件夹
比如你的Service是这样访问的 net.tcp://xxxxxx:4502/DuplexService/Service1.svc
但是SL会这样去request你的cross domain file : http://xxxxx/clientaccesspolicy.xml
- 已标记为答案 Min-Hong Tang - MSFT 2010年5月13日 4:34
-
你好,
我下载了你的例子,在code上没有错误。
可以正常的work.
从你的错误信息看一般可能是由于,你的防火墙吧这个端口block掉了。
建议你使用Fiddler来观察你的request是否成功获得clientaccesspolicy.xml,以及它是从哪个位置去request这个文件的。
你需要吧这个文件放在和你的virtual directory同级文件夹
比如你的Service是这样访问的 net.tcp://xxxxxx:4502/DuplexService/Service1.svc
但是SL会这样去request你的cross domain file : http://xxxxx/clientaccesspolicy.xml
这里也有两个帖子,
http://stackoverflow.com/questions/201004/why-cant-i-connect-to-a-wcf-service-with-net-tcp-but-i-can-with-http
http://stackoverflow.com/questions/201004/why-cant-i-connect-to-a-wcf-service-with-net-tcp-but-i-can-with-httpSilverlight 4 访问 wcf,net.tcp ,The connection attempt lasted for a time span ,无法建立连接,因为目标计算机主动拒绝连接
参考一下
Frank Xu Lei--谦卑若愚,好学若饥
专注于.NET平台下分布式应用系统开发和企业应用系统集成
Focus on Distributed Applications Development and EAI based on .NET
欢迎访问老徐的博客:Welcome to My Blog
欢迎访问老徐的网站:Welcome to My Website
欢迎访问微软WCF中文技术论坛:Welcome to Microsoft Chinese WCF Forum
欢迎访问微软WCF英文技术论坛:Welcome to Microsoft English WCF Forum