Connection Error in CRM 2011 Plugin

ReceRe

Recently one of my colleagues was facing an issue while executing a plugin in CRM 2011 OnPremise environment. In his plugin he was trying to push some data from CRM to Facebook using webservice exposed by Facebook.

 

The Web Service plug-in failed in OrganizationId: e04e7680-a484-e211-8a47-00155d8863b2; SdkMessageProcessingStepId: 1e269463-4795-e211-adef-00155d8863b2; EntityName: new_post; Stage: 20; MessageName: Create; AssemblyName: XYZ.Plugin.PushToFacebook, XYZ.Plugin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c345a3907d3249f7; ClassName: XYZ.Plugin.PushToFacebook; Exception: Unhandled Exception: System.Net.WebException: Unable to connect to the remote server

   at XYZ.Plugin.PushToFacebook.Process(String message, String facebookPathPostId, IOrganizationService service)

   at XYZ.Plugin.PushToFacebook.Execute(IServiceProvider serviceProvider)

   at Microsoft.Crm.Extensibility.V5PluginProxyStep.ExecuteInternal(PipelineExecutionContext context)

   at Microsoft.Crm.Extensibility.VersionedPluginProxyStepBase.Execute(PipelineExecutionContext context)

Inner Exception: System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 31.13.77.39:443

   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)

   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)

 

He complained that same plugin worked fine for him in OnLine scenario but failed in OnPremise.

 

In this particular scenario exception message clearly said that “A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond” the connection was not getting established properly

Things which could be causing problems:

  1. No Internet Exception – Check à Machine was connected to internet, he was able to explore service through browser
  2. Firewall – Check à Exception was set for specified ports for both inbound and outbound.
  3. Proxy – Check à It was set in LAN Settings in browser (Oooopsssss….)

 

So here was the problem, proxy was set for browser, not system/environment wide. So I asked him to use WebProxy object to make his call from plugin via proxy server and everything started working fine.

 

You can go through given link for looking into webproxy object:

http://msdn.microsoft.com/en-us/library/system.net.webproxy(v=vs.90).aspx

 

Do comment if you find same exception and this solution doesn’t work.

Leave a Reply

Your email address will not be published. Required fields are marked *