Server application won't bind to ports on IP address other than my internal ones

classic Classic list List threaded Threaded
44 messages Options
123
Reply | Threaded
Open this post in threaded view
|

Server application won't bind to ports on IP address other than my internal ones

Boost - Users mailing list

I have a server application that I wrote.  It currently doesn't bind to any ports on any IP address other than my computer's internal IP addresses (the localhost and 192.168.x.x ones). The application is the one whose source code is on GitHub here.

I used the asynchronous server and client examples from the Boost.Beast GitHub repository for the networking code (this link for the server: link; this link for the client: link). But when I run it using my external IP address, I get the error documented on lines 471 and 472:

// Bind to the server address
acceptor_.bind(endpoint, ec);
if (ec)
{
    std::cerr << "Lines 471 and 472:\n";
    fail(ec, "bind");
    return;
}

with the error itself being:

bind: The requested address is not valid in its context

And I've heard from whoever has tried to download and then run the server application that it just closes on its own after a while. I also tried to deploy it to Heroku as a Docker container before and found that it wouldn't bind to any ports they tried to bind it to and they had to kill it with SIGKILL.

I tried to look for the code for bind in Asio, but I don't really know where to look. Some help on that would also be appreciated. I might be able to figure it from reading that code. If I can't, I'll come back here.



_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Server application won't bind to ports on IP address other than my internal ones

Boost - Users mailing list
On 1/6/19 7:28 PM, Osman Zakir via Boost-users wrote:

> I have a server application that I wrote.  It currently doesn't bind to
> any ports on any IP address other than my computer's internal IP
> addresses (the localhost and 192.168.x.x ones). The application is the
> one whose source code is on GitHub here
> <https://github.com/DragonOsman/currency_converter/>.
>
> I used the asynchronous server and client examples from the Boost.Beast
> GitHub repository for the networking code (this link for the server:
> link
> <https://github.com/boostorg/beast/blob/develop/example/http/server/async/http_server_async.cpp>;
> this link for the client: link
> <https://github.com/boostorg/beast/blob/develop/example/http/client/async/http_client_async.cpp>).
> But when I run it using my external IP address, I get the error
> documented on lines 471 and 472:

Your computer probably is behind the NAT (Network Address Translation)
of your ISP -- so it has no knowledge of your external IP. You can try
that by running `ip addr` or `ipconfig` in the terminal (For windows:
Press Win+R and type cmd, for mac: search for Terminal, if you use linux
you should know how to start it)

Most likely it will not show you your external IP. Almost all internet
service providers will not allocate you a static IP but instead use NAT
to get around the limitations of IPv4. That is expected -- you probably
have to debug it locally with your local IP and then buy a VPS to make
your application available to the general internet.

>
> // Bind to the server address
> acceptor_.bind(endpoint, ec);
> if (ec)
> {
>     std::cerr << "Lines 471 and 472:\n";
>     fail(ec, "bind");
>     return;
> }
>
> with the error itself being:
>
> |bind: The requested address is not valid in its context |
>
> And I've heard from whoever has tried to download and then run the
> server application that it just closes on its own after a while. I also
> tried to deploy it to Heroku as a Docker container before and found that
> it wouldn't bind to any ports they tried to bind it to and they had to
> kill it with SIGKILL.
>
> I tried to look for the code for |bind| in Asio, but I don't really know
> where to look. Some help on that would also be appreciated. I might be
> able to figure it from reading that code. If I can't, I'll come back here.
>
>
>
> _______________________________________________
> Boost-users mailing list
> [hidden email]
> https://lists.boost.org/mailman/listinfo.cgi/boost-users
>

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Server application won't bind to ports on IP address other than my internal ones

Boost - Users mailing list
It doesn't bind to any IP address that Heroku tries to bind it to, when I try to deploy it there with a Dockerfile, either.  And whenever someone downloads the app and tries to run it, it won't bind to any port they try to bind it to either (and in this case it applies to internal IP addresses too).  This is a huge problem.

From: Boost-users <[hidden email]> on behalf of Geert Martin Ijewski via Boost-users <[hidden email]>
Sent: Monday, January 7, 2019 12:41 AM
To: [hidden email]
Cc: Geert Martin Ijewski
Subject: Re: [Boost-users] Server application won't bind to ports on IP address other than my internal ones
 
On 1/6/19 7:28 PM, Osman Zakir via Boost-users wrote:
> I have a server application that I wrote.  It currently doesn't bind to
> any ports on any IP address other than my computer's internal IP
> addresses (the localhost and 192.168.x.x ones). The application is the
> one whose source code is on GitHub here
> <https://github.com/DragonOsman/currency_converter/>.
>
> I used the asynchronous server and client examples from the Boost.Beast
> GitHub repository for the networking code (this link for the server:
> link
> <https://github.com/boostorg/beast/blob/develop/example/http/server/async/http_server_async.cpp>;
> this link for the client: link
> <https://github.com/boostorg/beast/blob/develop/example/http/client/async/http_client_async.cpp>).
> But when I run it using my external IP address, I get the error
> documented on lines 471 and 472:

Your computer probably is behind the NAT (Network Address Translation)
of your ISP -- so it has no knowledge of your external IP. You can try
that by running `ip addr` or `ipconfig` in the terminal (For windows:
Press Win+R and type cmd, for mac: search for Terminal, if you use linux
you should know how to start it)

Most likely it will not show you your external IP. Almost all internet
service providers will not allocate you a static IP but instead use NAT
to get around the limitations of IPv4. That is expected -- you probably
have to debug it locally with your local IP and then buy a VPS to make
your application available to the general internet.

>
> // Bind to the server address
> acceptor_.bind(endpoint, ec);
> if (ec)
> {
>     std::cerr << "Lines 471 and 472:\n";
>     fail(ec, "bind");
>     return;
> }
>
> with the error itself being:
>
> |bind: The requested address is not valid in its context |
>
> And I've heard from whoever has tried to download and then run the
> server application that it just closes on its own after a while. I also
> tried to deploy it to Heroku as a Docker container before and found that
> it wouldn't bind to any ports they tried to bind it to and they had to
> kill it with SIGKILL.
>
> I tried to look for the code for |bind| in Asio, but I don't really know
> where to look. Some help on that would also be appreciated. I might be
> able to figure it from reading that code. If I can't, I'll come back here.
>
>
>
> _______________________________________________
> Boost-users mailing list
> [hidden email]
> https://lists.boost.org/mailman/listinfo.cgi/boost-users
>

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Server application won't bind to ports on IP address other than my internal ones

Boost - Users mailing list
The network stack can only bind an acceptor (underneath it's a socket) to an address currently mapped into the IP network stack of the machine, docker container or VM - depending on where you are running it.

On many hosting services, the external (visible to the world) IP address is not actually on the same machine on which you are running your application. There is usually a facility to map/route the external IP address and port onto the private IP address of your application server.

This is not a failure of ASIO, just a consequence of the architectural deployment choices of you and/or your hosting company.


On a separate note, the fact that your server stops after a while seems unrelated. It will be due to a logic error in your code.
 

On Mon, 7 Jan 2019 at 02:48, Osman Zakir via Boost-users <[hidden email]> wrote:
It doesn't bind to any IP address that Heroku tries to bind it to, when I try to deploy it there with a Dockerfile, either.  And whenever someone downloads the app and tries to run it, it won't bind to any port they try to bind it to either (and in this case it applies to internal IP addresses too).  This is a huge problem.

From: Boost-users <[hidden email]> on behalf of Geert Martin Ijewski via Boost-users <[hidden email]>
Sent: Monday, January 7, 2019 12:41 AM
To: [hidden email]
Cc: Geert Martin Ijewski
Subject: Re: [Boost-users] Server application won't bind to ports on IP address other than my internal ones
 
On 1/6/19 7:28 PM, Osman Zakir via Boost-users wrote:
> I have a server application that I wrote.  It currently doesn't bind to
> any ports on any IP address other than my computer's internal IP
> addresses (the localhost and 192.168.x.x ones). The application is the
> one whose source code is on GitHub here
> <https://github.com/DragonOsman/currency_converter/>.
>
> I used the asynchronous server and client examples from the Boost.Beast
> GitHub repository for the networking code (this link for the server:
> link
> <https://github.com/boostorg/beast/blob/develop/example/http/server/async/http_server_async.cpp>;
> this link for the client: link
> <https://github.com/boostorg/beast/blob/develop/example/http/client/async/http_client_async.cpp>).
> But when I run it using my external IP address, I get the error
> documented on lines 471 and 472:

Your computer probably is behind the NAT (Network Address Translation)
of your ISP -- so it has no knowledge of your external IP. You can try
that by running `ip addr` or `ipconfig` in the terminal (For windows:
Press Win+R and type cmd, for mac: search for Terminal, if you use linux
you should know how to start it)

Most likely it will not show you your external IP. Almost all internet
service providers will not allocate you a static IP but instead use NAT
to get around the limitations of IPv4. That is expected -- you probably
have to debug it locally with your local IP and then buy a VPS to make
your application available to the general internet.

>
> // Bind to the server address
> acceptor_.bind(endpoint, ec);
> if (ec)
> {
>     std::cerr << "Lines 471 and 472:\n";
>     fail(ec, "bind");
>     return;
> }
>
> with the error itself being:
>
> |bind: The requested address is not valid in its context |
>
> And I've heard from whoever has tried to download and then run the
> server application that it just closes on its own after a while. I also
> tried to deploy it to Heroku as a Docker container before and found that
> it wouldn't bind to any ports they tried to bind it to and they had to
> kill it with SIGKILL.
>
> I tried to look for the code for |bind| in Asio, but I don't really know
> where to look. Some help on that would also be appreciated. I might be
> able to figure it from reading that code. If I can't, I'll come back here.
>
>
>
> _______________________________________________
> Boost-users mailing list
> [hidden email]
> https://lists.boost.org/mailman/listinfo.cgi/boost-users
>

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users




_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Server application won't bind to ports on IP address other than my internal ones

Boost - Users mailing list
On 7/01/2019 16:58, Richard Hodges wrote:
> The network stack can only bind an acceptor (underneath it's a socket)
> to an address currently mapped into the IP network stack of the machine,
> docker container or VM - depending on where you are running it.
>
> On many hosting services, the external (visible to the world) IP address
> is not actually on the same machine on which you are running your
> application. There is usually a facility to map/route the external IP
> address and port onto the private IP address of your application server.

If you're running it on a home (or small office) network, then it is
typically your Internet router which actually "has" the external IP; you
will need to configure port forwarding in this device to map a port from
the external IP to a port on an internal-network IP.

Bear in mind that your ISP may have restrictions against (and might
block, especially if they are doing another layer of NAT) servers hosted
in a home network -- especially in-development ones; and of course there
are security concerns with doing so as well.  And home external IPs are
dynamic, so will change from time to time, making them awkward to use
long-term.
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Server application won't bind to ports on IP address other than my internal ones

Boost - Users mailing list
I did set up port forwarding on my router for the port I wanted to use.  But yeah, I noticed that my external IP changed.  My 192.168.x.x IP address is static now, but the external one is still dynamic.  

The server doesn't stop on my machine, it stops on machines it's downloaded to.  And Heroku has to give it the SIGKILL signal after a while because it won't bind to any ports.  

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Server application won't bind to ports on IP address other than my internal ones

Boost - Users mailing list
If you guys haven't already, I'd like to ask you to read my app's source code.  Especially the C++ code.  And please also actually get the code and try to run it (though for that you'll need Jinja2Cpp and Nlohmann/JSON and also a Google Maps API Key and currencylayer.com API access key).  I need some help in debugging the networking code.  I also opened an issue about this ten days on the Boost.Asio GitHub, the link for which is: https://github.com/boostorg/asio/issues/184 .  The link to my app's code on GitHub is there, as well as the links to the Boost.Beast example code that I used (note: I didn't write the networking code myself; I just used the examples given on Beast's GitHub repository and extended it to also handle POST requests).  

If there's any info you guys need that I haven't given yet, let me know and I'll give it.  


From: Osman Zakir <[hidden email]>
Sent: Monday, January 7, 2019 6:24 PM
To: [hidden email]
Subject: Re: [Boost-users] Server application won't bind to ports on IP address other than my internal ones
 
I did set up port forwarding on my router for the port I wanted to use.  But yeah, I noticed that my external IP changed.  My 192.168.x.x IP address is static now, but the external one is still dynamic.  

The server doesn't stop on my machine, it stops on machines it's downloaded to.  And Heroku has to give it the SIGKILL signal after a while because it won't bind to any ports.  

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Server application won't bind to ports on IP address other than my internal ones

Boost - Users mailing list
On Thu, 10 Jan 2019 at 12:15, Osman Zakir via Boost-users <[hidden email]> wrote:
If you guys haven't already, I'd like to ask you to read my app's source code.  Especially the C++ code.  And please also actually get the code and try to run it (though for that you'll need Jinja2Cpp and Nlohmann/JSON and also a Google Maps API Key and currencylayer.com API access key).  I need some help in debugging the networking code.  I also opened an issue about this ten days on the Boost.Asio GitHub, the link for which is: https://github.com/boostorg/asio/issues/184 .  The link to my app's code on GitHub is there, as well as the links to the Boost.Beast example code that I used (note: I didn't write the networking code myself; I just used the examples given on Beast's GitHub repository and extended it to also handle POST requests).  

If there's any info you guys need that I haven't given yet, let me know and I'll give it.

You're kiddin' right?

You are actually asking [some pretty busy] people to [get acquainted with, and] debug your code for you, for free, I presume. Iff you have a minimal example exposing you're problem, maybe some help might come your way, but you're already sighting a gazillion dependencies, the problem could be anywhere [but most probably in your own code, look there, check invariants, assumptions you make and re-read docs pertaining to your dependencies]. You write: "... I just used the examples given on Beast's GitHub repository and extended it to also handle POST requests)", that sounds like a likely candidate [the "just" doesn't sound right in my ear].

degski
--
If something cannot go on forever, it will stop" - Herbert Stein

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Server application won't bind to ports on IP address other than my internal ones

Boost - Users mailing list
The problem is mostly likely in ASIO, Beast, or my extension networking code.  The dependencies are for Google Maps, currency conversion, JSON data and HTML templates.  There's nothing there to affect server app not being able to bind to ports, is there?  The problem is only about binding to ports.  

I get an error that's triggered from this piece of code (it's on lines 467 to 474 in the C++ code, including the one-line comment above that first line shown here): [It's an error from bind() which should be in Asio, but I don't know where to look for the definition.]
      

acceptor_.bind(endpoint, ec);
if (ec)
{
    std::cerr << "Lines 471 and 472:\n";
    fail(ec, "bind");
    return;
}





From: degski <[hidden email]>
Sent: Thursday, January 10, 2019 4:15 PM
To: [hidden email]
Cc: Osman Zakir
Subject: Re: [Boost-users] Server application won't bind to ports on IP address other than my internal ones
 
On Thu, 10 Jan 2019 at 12:15, Osman Zakir via Boost-users <[hidden email]> wrote:
If you guys haven't already, I'd like to ask you to read my app's source code.  Especially the C++ code.  And please also actually get the code and try to run it (though for that you'll need Jinja2Cpp and Nlohmann/JSON and also a Google Maps API Key and currencylayer.com API access key).  I need some help in debugging the networking code.  I also opened an issue about this ten days on the Boost.Asio GitHub, the link for which is: https://github.com/boostorg/asio/issues/184 .  The link to my app's code on GitHub is there, as well as the links to the Boost.Beast example code that I used (note: I didn't write the networking code myself; I just used the examples given on Beast's GitHub repository and extended it to also handle POST requests).  

If there's any info you guys need that I haven't given yet, let me know and I'll give it.

You're kiddin' right?

You are actually asking [some pretty busy] people to [get acquainted with, and] debug your code for you, for free, I presume. Iff you have a minimal example exposing you're problem, maybe some help might come your way, but you're already sighting a gazillion dependencies, the problem could be anywhere [but most probably in your own code, look there, check invariants, assumptions you make and re-read docs pertaining to your dependencies]. You write: "... I just used the examples given on Beast's GitHub repository and extended it to also handle POST requests)", that sounds like a likely candidate [the "just" doesn't sound right in my ear].

degski
--
If something cannot go on forever, it will stop" - Herbert Stein

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Server application won't bind to ports on IP address other than my internal ones

Boost - Users mailing list
The declaration for accepter_ is here (in the listener class definition):

{
tcp::acceptor acceptor_;
tcp::socket socket_;
std::shared_ptr<const std::string> doc_root_;
                 ...

From: Osman Zakir <[hidden email]>
Sent: Thursday, January 10, 2019 4:30 PM
To: [hidden email]
Subject: Re: [Boost-users] Server application won't bind to ports on IP address other than my internal ones
 
The problem is mostly likely in ASIO, Beast, or my extension networking code.  The dependencies are for Google Maps, currency conversion, JSON data and HTML templates.  There's nothing there to affect server app not being able to bind to ports, is there?  The problem is only about binding to ports.  

I get an error that's triggered from this piece of code (it's on lines 467 to 474 in the C++ code, including the one-line comment above that first line shown here): [It's an error from bind() which should be in Asio, but I don't know where to look for the definition.]
      

acceptor_.bind(endpoint, ec);
if (ec)
{
    std::cerr << "Lines 471 and 472:\n";
    fail(ec, "bind");
    return;
}





From: degski <[hidden email]>
Sent: Thursday, January 10, 2019 4:15 PM
To: [hidden email]
Cc: Osman Zakir
Subject: Re: [Boost-users] Server application won't bind to ports on IP address other than my internal ones
 
On Thu, 10 Jan 2019 at 12:15, Osman Zakir via Boost-users <[hidden email]> wrote:
If you guys haven't already, I'd like to ask you to read my app's source code.  Especially the C++ code.  And please also actually get the code and try to run it (though for that you'll need Jinja2Cpp and Nlohmann/JSON and also a Google Maps API Key and currencylayer.com API access key).  I need some help in debugging the networking code.  I also opened an issue about this ten days on the Boost.Asio GitHub, the link for which is: https://github.com/boostorg/asio/issues/184 .  The link to my app's code on GitHub is there, as well as the links to the Boost.Beast example code that I used (note: I didn't write the networking code myself; I just used the examples given on Beast's GitHub repository and extended it to also handle POST requests).  

If there's any info you guys need that I haven't given yet, let me know and I'll give it.

You're kiddin' right?

You are actually asking [some pretty busy] people to [get acquainted with, and] debug your code for you, for free, I presume. Iff you have a minimal example exposing you're problem, maybe some help might come your way, but you're already sighting a gazillion dependencies, the problem could be anywhere [but most probably in your own code, look there, check invariants, assumptions you make and re-read docs pertaining to your dependencies]. You write: "... I just used the examples given on Beast's GitHub repository and extended it to also handle POST requests)", that sounds like a likely candidate [the "just" doesn't sound right in my ear].

degski
--
If something cannot go on forever, it will stop" - Herbert Stein

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Server application won't bind to ports on IP address other than my internal ones

Boost - Users mailing list
I just tried commenting out the POST request handling code and the client_session stuff, and then tried to run it with my external IP, but the same error from bind() came up saying that the requested address is not valid in its context.  I also tried using the wildcard IP 0.0.0.0 as the command line argument for the address when running the server and entering my external IP into the browser address bar, but I still couldn't visit the app in the browser (can't get to it either way).  The problem is probably in the server code, and is because of Asio (probably).  I need some advice on how best to confirm this and troubleshoot the problem.  Thanks in advance.

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Server application won't bind to ports on IP address other than my internal ones

Boost - Users mailing list
What is more likely?

A. Asio, a library written by one of the most talented people on the planet, maintained for 15 years and running in millions of servers around the world has a bug in it that only you have found?

B. You have an incomplete understanding of how to deploy network servers behind a firewall.

Take all the time you need.

On Thu, 10 Jan 2019, 16:50 Osman Zakir via Boost-users <[hidden email] wrote:
I just tried commenting out the POST request handling code and the client_session stuff, and then tried to run it with my external IP, but the same error from bind() came up saying that the requested address is not valid in its context.  I also tried using the wildcard IP 0.0.0.0 as the command line argument for the address when running the server and entering my external IP into the browser address bar, but I still couldn't visit the app in the browser (can't get to it either way).  The problem is probably in the server code, and is because of Asio (probably).  I need some advice on how best to confirm this and troubleshoot the problem.  Thanks in advance.
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Server application won't bind to ports on IP address other than my internal ones

Boost - Users mailing list
It's definitely the second one.  I don't even need all the time in the world to figure that out.  But why is bind() telling me that my external IP address is invalid?  How do I find out what happened?  I'm no expert in network programming, so I need some help here.  

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Server application won't bind to ports on IP address other than my internal ones

Boost - Users mailing list
On 10/01/2019 18:21, Osman Zakir via Boost-users wrote:
> It's definitely the second one.  I don't even need all the time in the
> world to figure that out.  But why is bind() telling me that my
> external IP address is invalid?  How do I find out what happened?  I'm
> no expert in network programming, so I need some help here.

Perhaps you are behind a NAT router and are using port forwarding to
route traffic to and from your deployment host. That host will have no
network interfaces with the address that is your publicly visible IP
address so you cannot bind to that address, but you do not need to, just
bind to the address of a network interface that is connected to the
router, the NAT translation and port forwarding will do the rest for
you. You can also, more easily, bind to the wildcard address and let
your local router work out how to route traffic.

Regards
Bill Somerville.

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Server application won't bind to ports on IP address other than my internal ones

Boost - Users mailing list
In reply to this post by Boost - Users mailing list
On your internal server in a cobsile, type:

netstat -an | grep inet

Note the IP addresses. These are the only addresses available on your server.

You are not supplying one of these addresses to bind via the endpoint.

Therefore, error.



On Thu, 10 Jan 2019, 19:21 Osman Zakir via Boost-users <[hidden email] wrote:
It's definitely the second one.  I don't even need all the time in the world to figure that out.  But why is bind() telling me that my external IP address is invalid?  How do I find out what happened?  I'm no expert in network programming, so I need some help here.  
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Server application won't bind to ports on IP address other than my internal ones

Boost - Users mailing list
Thanks for that, but then why is it not binding to a port when Heroku tries to bind it?  Is Heroku also running behind a firewall on my computer?

From: Boost-users <[hidden email]> on behalf of Richard Hodges via Boost-users <[hidden email]>
Sent: Thursday, January 10, 2019 11:31 PM
To: Thomas Quarendon via Boost-users
Cc: Richard Hodges
Subject: Re: [Boost-users] Server application won't bind to ports on IP address other than my internal ones
 
On your internal server in a cobsile, type:

netstat -an | grep inet

Note the IP addresses. These are the only addresses available on your server.

You are not supplying one of these addresses to bind via the endpoint.

Therefore, error.



On Thu, 10 Jan 2019, 19:21 Osman Zakir via Boost-users <[hidden email] wrote:
It's definitely the second one.  I don't even need all the time in the world to figure that out.  But why is bind() telling me that my external IP address is invalid?  How do I find out what happened?  I'm no expert in network programming, so I need some help here.  
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Server application won't bind to ports on IP address other than my internal ones

Boost - Users mailing list
On 11/01/2019 07:35, Osman Zakir wrote:
> Thanks for that, but then why is it not binding to a port when Heroku
> tries to bind it?  Is Heroku also running behind a firewall on my computer?

Define what you mean when you say "Heroku".  Because a quick Google says
that's a cloud platform, which suggests it doesn't run on your computer
at all.  In which case you would have to run Richard's command on the
cloud machine, not your own machine.

Normally in the server code you should just bind to 0.0.0.0 always, and
let the network configuration figure out which port to make externally
accessible.  It only really matters when you're trying to write a DMZ
app that provides different content or security for different network
routes on a multi-homed server, or similar discretionary cases.

Read a good book on how networks work.
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Server application won't bind to ports on IP address other than my internal ones

Boost - Users mailing list
I wrote a Dockerfile and tried to deploy it to Heroku (they accept Dockerfiles), but it wouldn't bind to any port they tried to bind it to.  My server application requires an IP address and a port number as two of the command line arguments required to run it (it actually requires more than two; they are: IP address, port, docroot, number of threads).  

I set up port forwarding on my router for port number 8443.  Then I tried to use that port with my app.  I tried passing in 0.0.0.0 as the IP address and entered my external IP address in the browser's address bar, but I saw an error page.  On MS Edge, I get that "Hmmm...can't reach this page" error page.  And when I click on "Details", I see an error message saying, "This website cannot be found." Error code is "INET_E_RESOURCE_NOT_FOUND".  I also tried to run it by giving my external IP address for that command line argument, but of course I got that error from accelerator::bind() about it being invalid in its context.  The server app didn't exit, but I did get that same error I mentioned when I tried to visit my external IP on port 8443 in my browser.  

I wrote the Dockerfile for a synchronous version of the app, and the current one I have is asynchronous (I'm running it with 2 threads because that's apparently all my processor can take since it has two cores).  I made it asynchronous because I wanted to port it to WebAssembly, but Jinja2Cpp and Asio are giving me problems on that so I decided to not do it (Jinja2Cpp doesn't work well with Clang on Windows and Emscripten uses LLVM, and there's an Emscripten port for standalone Asio but it's an earlier version).  I don't like how the asynchronous version needs me to use global variables, but there's nothing I can do about that here.  Maybe I switch back to the synchronous version?  I might.  

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Server application won't bind to ports on IP address other than my internal ones

Boost - Users mailing list
It sounds as if the problem is with the edge configuration of your Heroku deployment. 

Is there a way to test this by deploying a different application?

On Fri, 11 Jan 2019 at 17:15, Osman Zakir via Boost-users <[hidden email]> wrote:
I wrote a Dockerfile and tried to deploy it to Heroku (they accept Dockerfiles), but it wouldn't bind to any port they tried to bind it to.  My server application requires an IP address and a port number as two of the command line arguments required to run it (it actually requires more than two; they are: IP address, port, docroot, number of threads).  

I set up port forwarding on my router for port number 8443.  Then I tried to use that port with my app.  I tried passing in 0.0.0.0 as the IP address and entered my external IP address in the browser's address bar, but I saw an error page.  On MS Edge, I get that "Hmmm...can't reach this page" error page.  And when I click on "Details", I see an error message saying, "This website cannot be found." Error code is "INET_E_RESOURCE_NOT_FOUND".  I also tried to run it by giving my external IP address for that command line argument, but of course I got that error from accelerator::bind() about it being invalid in its context.  The server app didn't exit, but I did get that same error I mentioned when I tried to visit my external IP on port 8443 in my browser.  

I wrote the Dockerfile for a synchronous version of the app, and the current one I have is asynchronous (I'm running it with 2 threads because that's apparently all my processor can take since it has two cores).  I made it asynchronous because I wanted to port it to WebAssembly, but Jinja2Cpp and Asio are giving me problems on that so I decided to not do it (Jinja2Cpp doesn't work well with Clang on Windows and Emscripten uses LLVM, and there's an Emscripten port for standalone Asio but it's an earlier version).  I don't like how the asynchronous version needs me to use global variables, but there's nothing I can do about that here.  Maybe I switch back to the synchronous version?  I might.  
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users


--
Richard Hodges
office: +442032898513
home: +376841522
mobile: +376380212 (this will be *expensive* outside Andorra!)
skype: madmongo
facebook: hodges.r


_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Server application won't bind to ports on IP address other than my internal ones

Boost - Users mailing list
In reply to this post by Boost - Users mailing list
The error on Heroku and the MS Edge stuff I mentioned are separate things.  Please don't mix them up.  The error with Heroku when it can't get my server app to bind to any ports is a 404 Not Found error and in the browser it shows Heroku's own custom error page.  

When I said that about running the app and visiting the browser, I wasn't talking about Dockerfiles and Heroku, I was talking about just running the server app by itself on my computer.  Right now that's what I have to get to work first.  I'll try using a Dockerfile for it again after the port binding issue is fixed.  

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
123