Target machine actively refuses connection

Topics: Web site
Mar 9, 2008 at 12:52 PM

Hello everyone,

I am trying to work thru the Visual Studio 2008 Training Kit Labs and I am working on the "Introduction to Windows Communication Foundation" lab. I am also performing these labs on a Windows Vista development machine which happens to also be running Windows Live OneCare. I have finished the lab but when I try to run the web page that consumes the WCF service I get the message below. I know the service works as I can run the test client, input the correct values and get data back with no problems.

I thought this might be a Vista or a Live OneCare problem, so I copied everything to my Windows XP laptop which has all the VS2008 and .Net 3.5 Framework installed on it with no Live OneCare. Pulled up the solution in VS2008 and get the same exact error when I try to run the web page. Can anyone help me determine why both these machines are refusing the connection? Thanks..

Steve Graddy MCP, MCAD.Net
Orgbrat Consulting


No connection could be made because the target machine actively refused it 127.0.0.1:8080
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:8080

Source Error:


Line 374:
Line 375: public DinnerNow.Web.MenuSearchService.FindRestaurantResult[] FindRestaurants(DinnerNow.Web.MenuSearchService.RestaurantSearchInput input) {
Line 376: return base.Channel.FindRestaurants(input);
Line 377: }
Line 378:


Source File: C:\Work - VS.NET 2008\VS2008 Add-Ins\VS2008 Training Kit\Labs\WCF\Ex01-BuildingWCFServiceAndClient\end\Source\DinnerNow.Web\Service References\MenuSearchService\Reference.cs Line: 376

Stack Trace:


SocketException (0x274d): No connection could be made because the target machine actively refused it 127.0.0.1:8080
System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +1073657
System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) +33
System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) +217

WebException: Unable to connect to the remote server
System.Net.HttpWebRequest.GetRequestStream() +1534317
System.ServiceModel.Channels.WebRequestHttpOutput.GetOutputStream() +47

EndpointNotFoundException: Could not connect to http://localhost:8080/MenuSearchService/. TCP error code 10061: No connection could be made because the target machine actively refused it 127.0.0.1:8080.
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +2668969
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +717
DinnerNow.Web.MenuSearchService.IMenuSearchService.FindRestaurants(RestaurantSearchInput input) +0
DinnerNow.Web.MenuSearchService.MenuSearchServiceClient.FindRestaurants(RestaurantSearchInput input) in C:\Work - VS.NET 2008\VS2008 Add-Ins\VS2008 Training Kit\Labs\WCF\Ex01-BuildingWCFServiceAndClient\end\Source\DinnerNow.Web\Service References\MenuSearchService\Reference.cs:376
DinnerNow.Web.Default.Page_Load(Object sender, EventArgs e) in C:\Work - VS.NET 2008\VS2008 Add-Ins\VS2008 Training Kit\Labs\WCF\Ex01-BuildingWCFServiceAndClient\end\Source\DinnerNow.Web\Default.aspx.cs:34
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +33
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436


Apr 14, 2009 at 3:09 AM
I've encountered a near identical situation working through an example in "Learning WCF" ..... any insight is appreciated.

System.ServiceModel.EndpointNotFoundException was unhandled
  Message="Could not connect to http://localhost:8080/HelloIndigo/HelloIndigoService. TCP error code 10061: No connection could be made because the target machine actively refused it 127.0.0.1:8080. "
  Source="mscorlib"
  StackTrace:
    Server stack trace:
       at System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStream()
       at System.ServiceModel.Channels.HttpOutput.Send(TimeSpan timeout)
       at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.SendRequest(Message message, TimeSpan timeout)
       at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
       at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
       at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
    Exception rethrown at [0]:
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       at Client.ServiceProxy.IHelloIndigoService.HelloIndigo()
       at Client.Program.Main(String[] args) in C:\Users\Jon\Desktop\Learning WCF\Labs\Chapter1\ServiceFromScratch\Client\Program.cs:line 16
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.Net.WebException
       Message="Unable to connect to the remote server"
       Source="System"
       StackTrace:
            at System.Net.HttpWebRequest.GetRequestStream()
            at System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStream()
       InnerException: System.Net.Sockets.SocketException
            Message="No connection could be made because the target machine actively refused it 127.0.0.1:8080"
            Source="System"
            ErrorCode=10061
            NativeErrorCode=10061
            StackTrace:
                 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)
            InnerException:

Apr 14, 2009 at 3:25 AM

Unhandled Exception: System.ServiceModel.EndpointNotFoundException: Could not co
nnect to http://localhost:8080/HelloIndigo/HelloIndigoService. TCP error code 10
061: No connection could be made because the target machine actively refused it
127.0.0.1:8080.  ---> System.Net.WebException: Unable to connect to the remote s
erver ---> System.Net.Sockets.SocketException: No connection could be made becau
se the target machine actively refused it 127.0.0.1:8080
   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddre
ss socketAddress)
   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Sock
et s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state,
IAsyncResult asyncResult, Int32 timeout, Exception& exception)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.GetRequestStream()
   at System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStre
am()
   --- End of inner exception stack trace ---

Server stack trace:
   at System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStre
am()
   at System.ServiceModel.Channels.HttpOutput.Send(TimeSpan timeout)
   at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpCha
nnelRequest.SendRequest(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeS
pan timeout)
   at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message messag
e, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean on
eway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan tim
eout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCall
Message methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]:
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage req
Msg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgDa
ta, Int32 type)
   at Client.ServiceProxy.IHelloIndigoService.HelloIndigo()
   at Client.Program.Main(String[] args) in C:\Users\Jon\Desktop\Learning WCF\La
bs\Chapter1\ServiceFromScratch\Client\Program.cs:line 16
Press any key to continue . . .

line 16 is             string s = proxy.HelloIndigo();
namespace Client
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args == null) throw new ArgumentNullException("args");
            EndpointAddress ep = new
                EndpointAddress("http://localhost:8080/HelloIndigo/HelloIndigoService");

            ServiceProxy.IHelloIndigoService proxy = ChannelFactory<ServiceProxy.IHelloIndigoService>.
                CreateChannel(new BasicHttpBinding(), ep);
            string s = proxy.HelloIndigo();
            Console.WriteLine(s);
            Console.WriteLine("Press <ENTER> to terminate client.");
            Console.ReadLine();
        }
    }
}