2011-05-23 62 views
0

無論何時我嘗試執行System.Net.HttpWebRequest.GetRequestStream(),無論我撥打什麼URL,都會收到以下錯誤:Asp.Net錯誤:無法建立連接,因爲目標機器主動拒絕它

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) 
------------------------------------------------------------------------------------ 

我看了兩個不同的提供者的兩個不同的Url和我得到完全相同的錯誤,除了IP地址是不同的。

我檢查了防火牆設置,IIS設置和服務器設置,沒有什麼突出的。

更糟糕的是,代碼在使用IIS 7.5的外部服務器上工作,但配置相同,但在內部服務器上失敗。

我也有內部IP地址添加到兩個提供者的接受列表。

因此,該代碼工作良好的外部而不是內部。無論代碼如何,都沒有任何區別。

任何想法?

+0

任何代碼示例? – 2011-05-23 06:11:09

+0

更好的serverfault可能? – 2011-05-23 06:49:50

回答

0

從麻煩機命令提示嘗試這種情況:

telnet 55.55.55.55 80 

55.55.55.55代表遠程主機的IP地址。確保在包括80之後包括一個空格(端口)。

如果telnet無法連接,那麼應用程序和主機應用程序之間絕對存在問題 - 可能是防火牆或相關問題。

如果telnet可以連接,但你的應用程序仍然不能,那麼你已經合法地將其縮小到一個非常小的東西(應用程序)。

其他提示:

+1

這是代理。忘記IIS 7.5在自己的帳戶下運行web請求 – heads5150 2011-05-23 11:37:46

+0

在我的情況下,它也是代理。我的顧客忘了它。 – Sven 2018-01-22 18:50:31

1

你認爲這個例外對你說謊嗎?

「目標機器主動拒絕它」意味着目標機器收到連接請求,但決定拒絕它而不是接受它。這幾乎總是意味着端口上沒有任何請求被監聽。我想這可能意味着有些東西在傾聽,它看到了連接請求,並且它明確地拒絕了它。

您需要從「目標機器」找出爲什麼它「主動拒絕」連接嘗試。

+0

downvote的任何原因,或什麼? – 2011-12-22 15:30:08

相關問題