WCF TCP error

Hi,

when I ran my first WCF application, I got the following error.
I have no idea what this means..I found that the last endpoint is giving this error.
can anybody let me know how to fix this issue?

System.ServiceModel.CommunicationException: A TCP error (10013: An attempt was made to access a socket in a way forbidden by its access permissions) occurred while listening on IP Endpoint=0.0.0.0:8080. ---> System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions
   at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.Bind(EndPoint localEP)
   at System.ServiceModel.Channels.SocketConnectionListener.Listen()
   --- End of inner exception stack trace ---
   at System.ServiceModel.Channels.SocketConnectionListener.Listen()
   at System.ServiceModel.Channels.BufferedConnectionListener.Listen()
   at System.ServiceModel.Channels.ConnectionAcceptor.StartAccepting()
   at System.ServiceModel.Channels.ConnectionDemuxer.StartDemuxing(Action`1 viaDelegate)
   at System.ServiceModel.Channels.ConnectionDemuxer.StartDemuxing()
   at System.ServiceModel.Channels.ExclusiveTcpTransportManager.OnOpen()
   at System.ServiceModel.Channels.TransportManager.Open(TransportChannelListener channelListener)
   at System.ServiceModel.Channels.TransportManagerContainer.Open(SelectTransportManagersCallback selectTransportManagerCallback)
   at System.ServiceModel.Channels.TransportChannelListener.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.ConnectionOrientedTransportChannelListener.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.TcpChannelListener`2.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open()
   at Microsoft.Tools.SvcHost.ServiceHostHelper.OpenService(ServiceInfo info)
System.Net.Sockets.SocketException (0x80004005): An attempt was made to access a socket in a way forbidden by its access permissions
   at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.Bind(EndPoint localEP)
   at System.ServiceModel.Channels.SocketConnectionListener.Listen()

Now here is my code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;


namespace HelloWorldService
{
    [DataContract]
    public class Name
    {
        [DataMember]
        public string First;
        [DataMember]
        public string Last;
    }

    [ServiceContract]
    public interface IHelloWorld
    {
        [OperationContract]
        string SayHello(Name Person);
    }
    public class HelloWorldService: IHelloWorld
    {       
        public string SayHello(Name Person)
        {
            return string.Format("Hello {0} {1}",
                Person.First, Person.Last);
        }
    }
}

Open in new window


And here is my App.config file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" />
  </system.web>
  <!-- When deploying the service library project, the content of the config file must be added to the host's 
  app.config file. System.Configuration does not support config files for libraries. -->
  <system.serviceModel>
    <services>
      <service name="HelloWorldService.HelloWorldService">
        <host>
          <baseAddresses>
            <add baseAddress = "http://localhost:8080/helloworld" />
          </baseAddresses>
        </host>
        <!-- Service Endpoints -->
        <!-- Unless fully qualified, address is relative to base address supplied above -->
        <endpoint address="ws" 
                  binding="wsHttpBinding" 
                  contract="HelloWorldService.IHelloWorld"/>
        <endpoint address="basic" 
                  binding="basicHttpBinding" 
                  contract="HelloWorldService.IHelloWorld"/>
         <endpoint address="net.tcp://localhost:8080/helloworld" 
                  binding="netTcpBinding" 
                  contract="HelloWorldService.IHelloWorld"/>
        
        <!-- Metadata Endpoints -->
        <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. --> 
        <!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, 
          set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
          <!-- To receive exception details in faults for debugging purposes, 
          set the value below to true.  Set to false before deployment 
          to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

</configuration>

Open in new window

IzzyTwinklyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mrwad99Commented:
10013 means either that port is blocked by your firewall, or another app is bound to it.  Can you please check your firewall settings then run netstat -a from a command prompt to see if anything else is bound?
0
IzzyTwinklyAuthor Commented:
Hi mrwad99,

Thank you so much.
However, it still gives me the same error even after I followed what you said.
00000.JPGI checked netstat -a after this setup. I couldn't found anything bound to 10013 nor 8080.00000.JPG
0
mrwad99Commented:
Hmm, OK:

Try

a) changing the port to something else other than 8080,

b) changing app.config to use 127.0.01 instead of localhost, or even your actual IP address.  Your stacktrace shows it is trying to bind to 0.0.0.0:8080 - now 0.0.0.0 means "all interfaces" so where it is getting 0.0.0.0 from I don't know...
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

IzzyTwinklyAuthor Commented:
Hi mrwad99,

I finally figured it out, but still don't understand.
As soon as I used the different port numbers between '<add baseAddress = "http://localhost:8080/helloworld" />' and '<endpoint address="net.tcp://localhost:8081/helloworld" ', it worked.
Do you know anything about this?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mrwad99Commented:
I'm very sorry but I cannot explain this; I'm not an expert on WCF but I do know a fair bit about TCP which is why I commented.  I'm glad you have it working though :)
0
IzzyTwinklyAuthor Commented:
no no..nothing to be sorry about. I found the answer because of you. you should get partial credit..thanks!!
0
mrwad99Commented:
Thank you Izzy, good luck in your future projects :)
0
IzzyTwinklyAuthor Commented:
mine worked
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
WCF

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.