CRM 365 returns 每次调用时出现 CommunicationException
CRM 365 returns CommunicationException on every call
我有一个调用 CRM 365 的服务。身份验证是使用 OAuth resp 完成的。不记名令牌。这很有效,但突然每次调用都会抛出 CommunicationException。可能是因为CRM版本更新到了v9.
这就是我创建 IOrganizationService 的方式:
var crmProxy = new OrganizationWebProxyClient(serviceUri, false)
{
HeaderToken = bearerToken
};
其中 serviceUri 类似于 https://mydomain.crm.dynamics.com/xrmservices/2011/organization.svc/web?SdkClientVersion=9.0.0.0
当我针对此代理进行调用时(例如 ExecuteRequest 或 RetrieveMultiple)一个 CommunicationException 抛出以下消息:
System.ServiceModel.CommunicationException: An error occurred while making the HTTP request to
https://mydomain.crm.dynamics.com/xrmservices/2011/organization.svc/web?SdkClientVersion=9.0.0.0.
This could be due to the fact that the server certificate is not
configured properly with HTTP.SYS in the HTTPS case. This could also
be caused by a mismatch of the security binding between the client and
the server. ---> System.Net.WebException: The underlying connection
was closed: An unexpected error occurred on a send. --->
System.IO.IOException: Unable to read data from the transport
connection: An existing connection was forcibly closed by the remote
host. ---> System.Net.Sockets.SocketException: An existing connection
was forcibly closed by the remote host
我已经将 CRM SDK 程序集更新到版本 9.0.2.4。还是不行。
我能做什么?
我找到了解决方案。
Dynamics 365 v9.0 强制执行 TLS 1.2。要在应用程序中强制执行 TLS 1.2,您必须在发出请求之前调用以下命令:
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
或者,您可以切换到 .Net 4.6 或更高版本。在这些版本中,TLS 1.2 是默认设置。
我有一个调用 CRM 365 的服务。身份验证是使用 OAuth resp 完成的。不记名令牌。这很有效,但突然每次调用都会抛出 CommunicationException。可能是因为CRM版本更新到了v9.
这就是我创建 IOrganizationService 的方式:
var crmProxy = new OrganizationWebProxyClient(serviceUri, false)
{
HeaderToken = bearerToken
};
其中 serviceUri 类似于 https://mydomain.crm.dynamics.com/xrmservices/2011/organization.svc/web?SdkClientVersion=9.0.0.0
当我针对此代理进行调用时(例如 ExecuteRequest 或 RetrieveMultiple)一个 CommunicationException 抛出以下消息:
System.ServiceModel.CommunicationException: An error occurred while making the HTTP request to https://mydomain.crm.dynamics.com/xrmservices/2011/organization.svc/web?SdkClientVersion=9.0.0.0. This could be due to the fact that the server certificate is not configured properly with HTTP.SYS in the HTTPS case. This could also be caused by a mismatch of the security binding between the client and the server. ---> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
我已经将 CRM SDK 程序集更新到版本 9.0.2.4。还是不行。
我能做什么?
我找到了解决方案。
Dynamics 365 v9.0 强制执行 TLS 1.2。要在应用程序中强制执行 TLS 1.2,您必须在发出请求之前调用以下命令:
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
或者,您可以切换到 .Net 4.6 或更高版本。在这些版本中,TLS 1.2 是默认设置。