none
A TCP error (10049: The requested address is not valid in its context)

    Question

  • Hello,

     

    When I try to listen and use my computer's external ip I get the error "A TCP error (10049: The requested address is not valid in its context) occurred while listening on IP Endpoint=218.166.32.38:808.

     

    Here is the code:

    ServiceHost sh = new ServiceHost(typeof(MathService));

    sh.AddServiceEndpoint(

    typeof(IMath), //contract type

    new NetTcpBinding(), //one of the built-in bindings

    "net.tcp://218.166.32.38/MathService/Ep1"); //the endpoint's address

    //create and open the service runtime

    sh.Open();

    System.Console.ReadLine();

    Tuesday, November 28, 2006 8:18 PM

Answers

  • You can't bind to an external IP. However, you can set up your router to forward incoming requests on a certain port to your machine's local IP.
    If you are trying to be accessible from the outside, it's best you subcribe to a DynDNS service as you have a non static IP, so you can always be reached even when your IP changed.
    Friday, December 1, 2006 8:26 PM
  • What are the valid IP addresses on the local computer (run ipconfig /all). If your IP address isn't on this list then your address is invalid. What exactly are you trying to accomplish in your scenario?
    Friday, December 1, 2006 6:16 PM
  • As I previously suggested, get a dyndns service like https://www.dyndns.com/ ... set your router up to register with it every time the IP changes (most routers support this). Additionally set your router up to forward port xxxx to your 192.168.xxx IP.
    When one of your customers tries to reach you at: myregistereddyndnsname.dyndns.com:xxxx they will be forwarded to your internal IP.
    Friday, December 1, 2006 11:00 PM

All replies

  • Hrmm -- this error usually results from an attempt to bind a listening socket to an IP address that's not valid for the local machine. Is that IP address static?
    -steve

    Thursday, November 30, 2006 11:54 PM
    Moderator
  • Hello,

     

    The IP is not static and I am using LinkSys router.  My ISP gives us an ADSL and we connect to the internet using LinkSys router.  I have used another router and it says the same error. It seems that I am getting an error with any error.

    But when I use the local IP 192.168.X.X, I do not get any error and it works fine.

    Friday, December 1, 2006 11:13 AM
  • What are the valid IP addresses on the local computer (run ipconfig /all). If your IP address isn't on this list then your address is invalid. What exactly are you trying to accomplish in your scenario?
    Friday, December 1, 2006 6:16 PM
  • Hello,

     

    When I run ipconfig /all, my IP address is 192.168.1.64, which is the local ip. When I give this IP it works fine, but when I give my external ip, obtained from whatismyip.org, it creates an error. For example when I enter an ip 182.33.21.44 which is not local it gives this error. Any none local IP, ip of any site, gives the same exception when I call Open().

     

    Is this because of our ISP? I have also changed the router to another, which is not LinkSys, and it still gives the same error.  I am in a countery where the ISP gives us dynamic IP and has firewall itself.

    Friday, December 1, 2006 7:38 PM
  • You can't bind to an external IP. However, you can set up your router to forward incoming requests on a certain port to your machine's local IP.
    If you are trying to be accessible from the outside, it's best you subcribe to a DynDNS service as you have a non static IP, so you can always be reached even when your IP changed.
    Friday, December 1, 2006 8:26 PM
  • Hello,

    Thank you for the help.

    Our client need to be connected over internet using our software. Our software which is an inventory software is developed in .NET. It has Remoting feature and computers can connect in a LAN.  But our customers need to connect two or more instances of our inventory software from internet or WAN.

    Unfortunately, in our country static IP is very expensive and we get static IP from the ADSL.

    We are to convert the remoting to WCF. But we  need a a host. We need a solution that helps us do this. So what is the best way?

    Friday, December 1, 2006 9:05 PM
  • As I previously suggested, get a dyndns service like https://www.dyndns.com/ ... set your router up to register with it every time the IP changes (most routers support this). Additionally set your router up to forward port xxxx to your 192.168.xxx IP.
    When one of your customers tries to reach you at: myregistereddyndnsname.dyndns.com:xxxx they will be forwarded to your internal IP.
    Friday, December 1, 2006 11:00 PM
  • Thanks for this , i have struggled with a service restart as i was getting this error:

    "Internal Error in Navision VT100Plugin...... ....Error Listening Connection......."

    Your suggestion for static IP resolved my issue

    Friday, February 23, 2018 12:53 PM