Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用Wcf客户端连接到安全群集的服务结构_C#_Wcf_Azure_Azure Service Fabric - Fatal编程技术网

C# 使用Wcf客户端连接到安全群集的服务结构

C# 使用Wcf客户端连接到安全群集的服务结构,c#,wcf,azure,azure-service-fabric,C#,Wcf,Azure,Azure Service Fabric,我无法建立到安全结构群集的Wcf连接。由于sotn的建议,在收集日志之后,问题是一个简单的TCP端点未找到异常(TCP代码10060)。端点肯定存在(fabric正在解析它,我只提供命名服务),当我检查集群设置时,端口实际上是打开的。因此,我认为安全方面一定有问题。但是,使用相同的凭据,我可以创建集群的结构客户端 群集由x509证书保护。我正在尝试创建一个wcf客户端,它可以从部署wcf服务的集群之外的VM使用。我按照指南设置了服务和服务 string serverCertThumb=“xxx”

我无法建立到安全结构群集的Wcf连接。由于sotn的建议,在收集日志之后,问题是一个简单的TCP端点未找到异常(TCP代码10060)。端点肯定存在(fabric正在解析它,我只提供命名服务),当我检查集群设置时,端口实际上是打开的。因此,我认为安全方面一定有问题。但是,使用相同的凭据,我可以创建集群的结构客户端

群集由x509证书保护。我正在尝试创建一个wcf客户端,它可以从部署wcf服务的集群之外的VM使用。我按照指南设置了服务和服务

string serverCertThumb=“xxx”;
字符串clientCertThumg=“xxx”;
string commonName=“mycluster.southcentralus.cloudapp.azure.com”;
string connection=“mycluster.southcentralus.cloudapp.azure.com:19000”;
var xc=GetCredentials(clientCertThumg、serverCertThumb、commonName);
var解析器=新的ServicePartitionResolver(xc,连接);
var myFactory=new WcfCommunicationClientFactory(wcfurtility.CreateTcpListenerBinding(),null,
解析程序,null,null);
var client=myFactory.CreateClient(new System.Uri(“fabric:/myservicecpath”);
静态X509Credentials GetCredentials(字符串clientCertThumb、字符串服务器CertThumb、字符串名称)
{
X509Credentials xc=新的X509Credentials();
xc.StoreLocation=StoreLocation.CurrentUser;
xc.StoreName=“我的”;
xc.FindType=X509FindType.FindByThumbprint;
xc.FindValue=clientCertThumb;
xc.RemoteCommonNames.Add(名称);
RemoteCertThumbprints.Add(serverCertThumb);
xc.ProtectionLevel=ProtectionLevel.EncryptAndSign;
返回xc;
}

你的问题是什么?我补充了一些说明。当我调用eg client.Channel.MyMethod()时,连接将打开(或尝试打开),然后无限期挂起。我没有得到超时或异常。我似乎无法找出问题所在,正在寻求任何建议。您是否在服务器和客户端中都尝试了wcf跟踪?我可能有误解,但由于运行的底层VMs服务结构被抽象掉,服务将不知道将跟踪文件记录到何处(或者至少我不知道如何找到它们,因为我不知道哪台机器正在运行该服务)检查或谷歌Azure WCF跟踪。否则,更难理解发生了什么。。
string serverCertThumb = "xxx";
string clientCertThumg = "xxx";
string commonName = "mycluster.southcentralus.cloudapp.azure.com";
string connection = " mycluster.southcentralus.cloudapp.azure.com:19000";

var xc = GetCredentials(clientCertThumg, serverCertThumb, commonName);
var resolver = new ServicePartitionResolver(xc, connection);
var myFactory = new WcfCommunicationClientFactory<IData>(WcfUtility.CreateTcpListenerBinding(), null,
    resolver, null, null);
var client = myFactory.CreateClient(new System.Uri("fabric:/MyServicePath"));

static X509Credentials GetCredentials(string clientCertThumb, string serverCertThumb, string name)
{
    X509Credentials xc = new X509Credentials();
    xc.StoreLocation = StoreLocation.CurrentUser;
    xc.StoreName = "My";
    xc.FindType = X509FindType.FindByThumbprint;
    xc.FindValue = clientCertThumb;
    xc.RemoteCommonNames.Add(name);
    xc.RemoteCertThumbprints.Add(serverCertThumb);
    xc.ProtectionLevel = ProtectionLevel.EncryptAndSign;
    return xc;
}