Whenever I try to do a System.Net.HttpWebRequest.GetRequestStream() no matter what the URL I am calling I got the below error:
Exception Type: System.Net.WebException
Message: Unable to connect to the remote server
Source: System
Stack Trace:
at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
at System.Net.HttpWebRequest.GetRequestStream()
at WorldVision.Sitefinity.Data.Business.WebServices.Viocorp.PreparePostRequest(WebRequest webRequest, NameValueCollection parameters) in c:\Inetpub\Websites\WvaFEGit\CmsWebsite\WorldVision.Sitefinity.Data\Business\WebServices\Viocorp.cs:line 167
at WorldVision.Sitefinity.Data.Business.WebServices.Viocorp.QueryWithParameters(ServiceType service, NameValueCollection parameters) in c:\Inetpub\Websites\WvaFEGit\CmsWebsite\WorldVision.Sitefinity.Data\Business\WebServices\Viocorp.cs:line 109
at WorldVision.Sitefinity.Data.Business.WebServices.Viocorp.QueryWithParameters(String serviceName, NameValueCollection parameters) in c:\Inetpub\Websites\WvaFEGit\CmsWebsite\WorldVision.Sitefinity.Data\Business\WebServices\Viocorp.cs:line 87
at WorldVision.Sitefinity.Data.Business.VioCorpVideoRepository.GetVideoByMediaId(String mediaId) in c:\Inetpub\Websites\WvaFEGit\CmsWebsite\WorldVision.Sitefinity.Data\Business\IVioCorpVideoRepository.cs:line 28
at WorldVision.Sitefinity.Modules.Story.WebControls.Design.VioCorpVideoControlDesigner.BindPresentation() in c:\Inetpub\Websites\WvaFEGit\CmsWebsite\WorldVision.Sitefinity.Modules\Story\WebControls\Design\VioCorpVideoControlDesigner.cs:line 143
at WorldVision.Sitefinity.Modules.Story.WebControls.Design.VioCorpVideoControlDesigner.BindVideo() in c:\Inetpub\Websites\WvaFEGit\CmsWebsite\WorldVision.Sitefinity.Modules\Story\WebControls\Design\VioCorpVideoControlDesigner.cs:line 136
at WorldVision.Sitefinity.Modules.Story.WebControls.Design.VioCorpVideoControlDesigner.Button_Command(Object sender, CommandEventArgs e) in c:\Inetpub\Websites\WvaFEGit\CmsWebsite\WorldVision.Sitefinity.Modules\Story\WebControls\Design\VioCorpVideoControlDesigner.cs:line 187
at System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e)
at System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
------------------------------------------------------------------------------------
- L1 -------------------------------------------------------------------------------
Exception Type: System.Net.Sockets.SocketException
Message: No connection could be made because the target machine actively refused it 210.247.216.66:80
Source: System
Stack Trace:
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
------------------------------------------------------------------------------------
I’ve looked at two different Urls from two different providers and I get exactly the same error apart from the IP address being different.
I’ve checked Firewall settings, IIS settings and server settings and nothing stands out.
To make matters worse the code works on an external server using IIS 7.5 with the same configuration but fails on an internal server.
I’ve also had the internal IP addresses added to the accepted lists of the two providers.
Therefore the code works fine externally and not internally. No differences in the code whatsoever.
Any ideas?
Try this from the troublesome machine command prompt:
55.55.55.55 represents the IP address of the remote host. Make sure to include a space after it, before including 80 (the port).
If telnet can’t connect, then there’s definitely a problem between your application and the host application — probably a firewall or related issue.
If telnet can connect, but your application still cannot, then you’ve legitimately narrowed it down to a very small thing (the application).
Other Tips: