I have a basic Contracts project:
[ServiceContract]
public interface IEchoService
{
[OperationContract]
string GetUpper(string text);
[OperationContract]
string GetLower(string text);
}
Service project:
public class EchoService : IEchoService
{
public string GetUpper(string text)
{
return text.ToUpper();
}
public string GetLower(string text)
{
return text.ToLower();
}
}
Self host project:
class Program
{
static void Main(string[] args)
{
var container = new WindsorContainer();
container.AddFacility<WcfFacility>(f => f.CloseTimeout = TimeSpan.Zero);
container
.Register(
AllTypes
.FromThisAssembly()
.InSameNamespaceAs<IEchoService>()
.WithServiceDefaultInterfaces()
.Configure(c =>
c.Named(c.Implementation.Name)
.AsWcfService(
new DefaultServiceModel()
.AddEndpoints(WcfEndpoint
.BoundTo(new NetTcpBinding(SecurityMode.None))
.At(string.Format(
"net.tcp://localhost:10333/MyServices/{0}",
c.Implementation.Name)
)))));
Console.WriteLine("hosting...");
while (Console.ReadKey().Key != ConsoleKey.Q)
{
}
}
When I tried connecting to my service from my client, I get this error msg:
Could not connect to net.tcp://localhost:10333/MyServices/EchoService. The connection attempt lasted for a time span of 00:00:02.0904037. TCP error code 10061: No connection could be made because the target machine actively refused it 127.0.0.1:10333.
So I checked netstat, and found out that my console service, while able to run, isn't even listening on port 10333. I have no other programs using that port, I have even changed to a few other port nubmers, but it just doesn't show up on netstat.
What could be wrong with my console service? or any configuration settings I might have missed out?