cpprestsdk icon indicating copy to clipboard operation
cpprestsdk copied to clipboard

Crash when using http_listener with public IP address

Open shomimn opened this issue 10 years ago • 11 comments

http_listener listener(U("http://xxx.xxx.xxx.xxx/test/"));
listener.support(methods::GET, [](http_request req) {});

listener.open().then([]()
{
    qDebug () << "then";
});

Previous code ends up crashing when xs are replaced with the public IP, and I haven't been able to catch an exception. Everything works as expected with the local IP.

Tested on: Windows 7 64bit with MSVC 2015 and cpprest v2.8 from nuget Ubuntu 15.10 64bit with GCC 5.2.1 and cpprest from master branch

shomimn avatar May 23 '16 12:05 shomimn

you should run command "netsh http add iplisten xxx.xxx.xxx.xxx" with user admin, then run the program with user admin

lmdu-gs avatar Jun 14 '16 09:06 lmdu-gs

After read, i found that run "netsh http add urlacl url=http://xxx.xxx.xxx.xxx/YourUrl user=USER_OR_GROUP" may more useful. see https://casablanca.codeplex.com/discussions/532385 and https://msdn.microsoft.com/en-us/library/windows/desktop/cc307223(v=vs.85).aspx

lmdu-gs avatar Jun 14 '16 11:06 lmdu-gs

I had a lot of problems with this, but for me on windows 10 worked just running the application With Administrative privileges (right click and run as Administrator). Not even need netsh is needed. It maybe not the best option, but it works.

raimuucka avatar Sep 28 '16 10:09 raimuucka

On Windows you always have to run as administrator to serve to a public IP address.

Damien

On September 28, 2016 4:25:43 AM raimuucka [email protected] wrote:

I had a lot of problems with this, but for me on windows 10 worked just running the application With Administrative privileges (right click and run as Administrator). Not even need netsh is needed.

You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/Microsoft/cpprestsdk/issues/164#issuecomment-250129707

damienhocking avatar Sep 28 '16 12:09 damienhocking

I have a similar problem except running the application with administrative rights doesn't change anything. See my stackoverflow question for more information.

jfgauron avatar Oct 14 '16 14:10 jfgauron

@damienhocking Any official documents regarding to administrator rights? I'd like to know why. Thanks.

sinall avatar Jun 10 '18 15:06 sinall

On windows 7 i was making cpp project tcp server wit 3??? Port without admin rights. So i do not know why this one needs admin rights on even bigger port number.

raimuucka avatar Jun 10 '18 16:06 raimuucka

I have the same problem. For me these two points work: 1- you have to set http_listener url as : "http://*:port". 2- run your code as admin

mahdisn76 avatar Aug 04 '19 08:08 mahdisn76

I has that problem, always running as admin, but server crashing every time when listener url not localhost. Please help Stackoverflow question

midnightspecia1 avatar Nov 27 '20 07:11 midnightspecia1

I has that problem, always running as admin, but server crashing every time when listener url not localhost. Please help Stackoverflow question

try netsh http add urlacl url=http://xxx.xxx.xxx.xxx/YourUrl user=USER_OR_GROUP

lmdu-gs avatar Nov 27 '20 07:11 lmdu-gs

I has that problem, always running as admin, but server crashing every time when listener url not localhost. Please help Stackoverflow question

try netsh http add urlacl url=http://xxx.xxx.xxx.xxx/YourUrl user=USER_OR_GROUP

Already tryed that, its all stays the same( Error that trowing right before crashing is "error adding url to a url group"

midnightspecia1 avatar Nov 27 '20 07:11 midnightspecia1