Quantcast
Channel: WE MOVED to github.com/microsoft/cpprestsdk. This site is not monitored!
Viewing all 4845 articles
Browse latest View live

Commented Issue: http_listener hangs on open() if pplx task is created in parallel on Win Server 20012 R2 [306]

$
0
0
http_listener.open() simply hangs if I pplx::create_task() {Sleep(forewer);} before hand.
If I first start listener and then launch the task, then all incoming http requests will hang.

This repros 100% on Windows 2012 R2 in Azure (Azure provided image), however it it doesn't repro on Win8.1 non-virtual machine. Win 8.1 non-virtual works just fine, but server hangs.
I use cpprest120d_2_2.dll
Code:
try
{
pplx::create_task([]
{
Sleep(1000000);
});

std::wcout << L"Launching" << std::endl;

listener
.open()
.then([&listener](){std::wcout << L"Start to listen"<<std::endl ; })
.wait();


while (true){ Sleep(1000); }
}
catch (exception const & e)
{
wcout << e.what() << endl;
}

otuput:

httpsample.exe localhost --c
url: http://localhost:9575/restdemo
Launching

// hangs right here




Comments: Hi Ruslan, Ok it sounds like this really is the same bug then. I'm closing this as a duplicate. Thanks, Steve

Closed Issue: http_listener hangs on open() if pplx task is created in parallel on Win Server 20012 R2 [306]

$
0
0
http_listener.open() simply hangs if I pplx::create_task() {Sleep(forewer);} before hand.
If I first start listener and then launch the task, then all incoming http requests will hang.

This repros 100% on Windows 2012 R2 in Azure (Azure provided image), however it it doesn't repro on Win8.1 non-virtual machine. Win 8.1 non-virtual works just fine, but server hangs.
I use cpprest120d_2_2.dll
Code:
try
{
pplx::create_task([]
{
Sleep(1000000);
});

std::wcout << L"Launching" << std::endl;

listener
.open()
.then([&listener](){std::wcout << L"Start to listen"<<std::endl ; })
.wait();


while (true){ Sleep(1000); }
}
catch (exception const & e)
{
wcout << e.what() << endl;
}

otuput:

httpsample.exe localhost --c
url: http://localhost:9575/restdemo
Launching

// hangs right here




New Post: Suitable algorithm to find an element in C++ Rest JSON

New Post: rest sdk http_listener as a network server

$
0
0
Guys,

You have to have IIS enabled, and be running the listener as an administrator.

Damien

Commented Feature: on-demand thread creation/lib initialization [68]

$
0
0
Hello,

I would like to use casablanca in a child process in Linux.

When the application starts the crossplat::threadpool::s_shared is automatically constructed in the parent process. However, the 40 threads are not inherited by the child process created by a fork call and, thus, I cannot use casablanca in the child process.

It would be helpful for me if I could control when the threads are created, a sort of init_casablanca() function.

Regards,
Sorin
Comments: A pull request has been merged that lazy instantiates the threadpool until actually needed. Now if you don't use anything with tasks it will be possible to fork another process. This change is in the development branch and will be in the master in 2.5.0. Steve

Closed Feature: on-demand thread creation/lib initialization [68]

$
0
0
Hello,

I would like to use casablanca in a child process in Linux.

When the application starts the crossplat::threadpool::s_shared is automatically constructed in the parent process. However, the 40 threads are not inherited by the child process created by a fork call and, thus, I cannot use casablanca in the child process.

It would be helpful for me if I could control when the threads are created, a sort of init_casablanca() function.

Regards,
Sorin

Updated Release: C++ Rest SDK 2.5.0

$
0
0
Android
  • Fixed issue in CMakeLists.txt where parenthesis were incorrectly used instead of brackets.
  • Fixed issue in CMakeLists.txt where pplxlinux.cpp source file was missing.
  • Added Android TestRunner packing androidproj to build.

Windows
  • Fixed several code analysis warnings.
  • Updating NuGet package for missing OpenSSL license, also patched 2.4.0's NuGet package.
  • Fixed not working on XP issue because of crypto API. #331, #334
  • Fixed several functions missing an explicit calling convention. This caused problems if you changed the calling convention from the cdecl.
  • Added support for Windows on Devices/Galileo. #217
  • Added option to force using PPLX on Windows Threadpool instead of PPL on the Concurrency Runtime. Library can be rebuilt using CPPREST_FORCE_PPLX macro.
  • Updated all binaries to use whole program optimizations, slightly decreasing binary size and small potential performance improvements.
  • Merged pull request adding support for CMake for Windows desktop.

OSX
  • Merged a pull request to work around a FindOpenSSL.cmake issue, enabling it to find Homebrew's copy.
  • Added support for iOS 64bit simulator. #196

websocket_client
  • Fixed a race condition in Websocket++ based implementation during websocket client destructor which would sometimes result in an AV/Segfault.
  • Added proxy support for Websocket++ based implementation.
  • Added support for Server Name Indication (SNI) to Websocket++ based implementation.
  • Updated server certificate verification to accept SERVER_GATED_CRYPTO and SGC_NETSCAPE usage for Websocket++ based implementation on Windows.

pplx
  • Merged a pull request lazy instantiating the underlying threadpool used. Allows for forking processes in certain circumstances. #68

http_client
  • Make std::function parameter to http_client::add_handler passed by const reference.
  • Fixed invalid check in WinHTTP based implementation causing autologon security level to be high if credentials are not provided.
  • Added extract_utf8string and extract_utf16string to http_request and http_response classes. This allows uses either UTF-8 or UTF-16, instead of utility::string_t, more efficiently regardless of the platform.
  • Implemented native handle API for non-Windows platforms exposing Boost.Asio structures. This allows for configuring additional options like client certificates for example. #168
  • Fixed bug in Boost.Asio based implementation that incorrectly caused multiple handshakes to occur when reusing connections with HTTPS.

json
  • Fixed issue where the JSON library assumes char is a signed type, however C++ doesn't guarantee this. On ARM with Clang for example char is an unsigned type. This lead to incorrect parsing.

Miscellaneous
  • Merged pull request adding http_constants.dat to be installed with 'make install'.

Tests
  • Fixed race conditions in close_callback_client_from_server
  • Added proper synchronization to test_websocket_server (preventing some race conditions). #305

New Post: rest sdk http_listener as a network server

$
0
0
@Damien: >> Why do you need IIS? http_listener in windows is implemented using httpsys API. Why would you need IIS? What is IIS role here?

New Post: rest sdk http_listener as a network server

$
0
0
I'm not at my system right now, but I'm pretty sure we had to enable IIS to be able to access the service from external IP addresses. Maybe Steve or someone else can jump in and provide official guidance.

Damien

New Post: rest sdk http_listener as a network server

$
0
0
I don't believe that you need to have IIS enabled to access from an external IP address. Variants on this discussion have come up quite a bit. As 000golabi mentions earlier in this thread, the main purpose of this library is for connecting to and consuming RESTful services.

For the http_listener on Windows, we build directly on top of the Windows HTTP Server API. So for listening to external requests you will have to follow the same rules. Specifically you need administrative privileges or have to have an admin make a reservation on a portion of the desired URI. See the HTTP Server API for more documentation.

Steve

Created Unassigned: connnect error when connect to websocket via proxy [347]

$
0
0
Hi,

I used casablanca(development branch lastest commit) to connect with websocket server via proxy.

```
websocket_callback_client client;
websocket_client_config client_config;
web::web_proxy wp(U("http://myproxyserver:8080"));
credentials cred("username","password");
wp.set_credentials(cred);
client_config.set_proxy(wp);
client = websocket_callback_client(client_config);

pplx::task<void> connectTask = client.connect(U(uri));
try {
connectTask.wait();
cout << "Connect success!" <<endl;

// Handle receive message

});

// Handle closing connection
client.set_close_handler([](websocket_close_status status, utility::string_t reason, std::error_code errCode) {
printf("Error exception:%s \n", errCode.message().c_str());
});

} catch (websocket_exception &e) {
}
```
unfortunately, after connect to server, immediately this connection was be closed, and throw this message "__Error exception:Undefined error: 0__"

All suggestions are welcome.
Thank you in advance.


Edited Unassigned: get error when connect to websocket via proxy [347]

$
0
0
Hi,

I used casablanca(development branch lastest commit) to connect with websocket server via proxy.

```
websocket_callback_client client;
websocket_client_config client_config;
web::web_proxy wp(U("http://myproxyserver:8080"));
credentials cred("username","password");
wp.set_credentials(cred);
client_config.set_proxy(wp);
client = websocket_callback_client(client_config);

pplx::task<void> connectTask = client.connect(U(uri));
try {
connectTask.wait();
cout << "Connect success!" <<endl;

// Handle receive message

});

// Handle closing connection
client.set_close_handler([](websocket_close_status status, utility::string_t reason, std::error_code errCode) {
printf("Error exception:%s \n", errCode.message().c_str());
});

} catch (websocket_exception &e) {
}
```
unfortunately, after connect to server, immediately this connection was be closed, and throw this message "__Error exception:Undefined error: 0__"

All suggestions are welcome.
Thank you in advance.


New Post: monitoring page

$
0
0
I want to create a page (html) that is displaying information about the state of my application, like display running in page until the application ends, and if I connect to the page, I'll see the app's status. I have started from a similar application, but it is getting more and more complicated. Is there a tutorial for such a thing? I want to refresh the page every some time.

Until now I have managed to do as this:
#pragma once

#include <functional>

#include <cpprest/basic_types.h>
#include <cpprest/http_msg.h>
#include <cpprest/http_listener.h>

class Monitoring
{
private:
    void handle_put(web::http::http_request message);
    void handle_post(web::http::http_request message);
    void handle_delete(web::http::http_request message);

    web::http::experimental::listener::http_listener m_listener;

public:
    Monitoring(utility::string_t url, std::function< void(web::http::http_request) > handler);

    pplx::task<void> open();
    pplx::task<void> close();
};
and in main I do:
utility::string_t address = U("http://" + server_addr + ":");
address.append(service_port);

onInit(address);

// my appli run

onEnd();
There is a global std::unique_ptr<Monitoring> gServer that is called in the two functions:
void onInit(const utility::string_t& address)
{
    web::uri_builder uri(address);

////// marked
    std::function<void(web::http::http_request)> har_func = std::bind(&server::request_handler::handle_a_request, request_handler, std::placeholders::_1);
//////
    gServer = std::unique_ptr<Server>(new Server(uri.to_uri().to_string(), har_func));

    gServer->open().wait();
}
and
void onExit()
{
    gServer->close().wait();
    return;
}
The marked is getting complicated. In fact there are more handle_a_request functions that are creating the tables that I have spoken in the beginning, and I am getting lost here... Maybe I don't even need that part.

P.S.: the server::request_handler is defined in the application (that I have inspired from), is there another simpler way to do it, like some implicit thing from cpprest?

New Post: rest sdk http_listener as a network server

$
0
0
What is server? is it defined by me, or it is something that cpprest has?

I have a somehow similar problem: I want to create a status page for my application. I have just posted the thread today, any help please?

Commented Unassigned: get error when connect to websocket via proxy [347]

$
0
0
Hi,

I used casablanca(development branch lastest commit) to connect with websocket server via proxy.

```
websocket_callback_client client;
websocket_client_config client_config;
web::web_proxy wp(U("http://myproxyserver:8080"));
credentials cred("username","password");
wp.set_credentials(cred);
client_config.set_proxy(wp);
client = websocket_callback_client(client_config);

pplx::task<void> connectTask = client.connect(U(uri));
try {
connectTask.wait();
cout << "Connect success!" <<endl;

// Handle receive message

});

// Handle closing connection
client.set_close_handler([](websocket_close_status status, utility::string_t reason, std::error_code errCode) {
printf("Error exception:%s \n", errCode.message().c_str());
});

} catch (websocket_exception &e) {
}
```
unfortunately, after connect to server, immediately this connection was be closed, and throw this message "__Error exception:Undefined error: 0__"

All suggestions are welcome.
Thank you in advance.


Comments: Hi najp, What is the websocket_close_status parameter value in when the close handler is being executed? Also does the connectTask successfully complete? Does the text "Connect success!" get printed to the console? Steve

New Post: monitoring page

$
0
0
Hi opreanstefan,

It is a little hard to follow the code here and understand exactly what you are asking for. I don't see the 'Server' class declared anywhere, but the http_listener is stored in a class called 'Monitoring'. What exactly is the purpose of this 'handle_a_request', is it to try and handle just a single HTTP request and not subsequent ones? I don't see why you need to have more request handlers.

In general the way you register handlers with our http_listener for requests is through the http_listener::support(...) APIs. There is one that can be used to handle all request, regardless of HTTP method, and another overload that can be used to register for specific HTTP methods.

Steve

New Post: rest sdk http_listener as a network server

$
0
0
Following up on Steve's response above, I disabled IIS on my test machines and the Casablanca-based services we have still work from external IPs (on Win 7 and 8.1). So:

1) You don't need IIS running for Casablanca-based listener services to work on Windows.
2) To provide services to external IPs, you need to be listening on http://*:xxxxx where xxxxx is your port number.
3) Your listener needs to be running with admin privileges, or have the reservation described above. There's more information on reservations here:

https://casablanca.codeplex.com/discussions/532385

4) You need to open up your firewall for the port(s) you're using. You need an incoming port rule for that, not an incoming program rule on a specific port.

Damien

Updated Release: C++ Rest SDK 2.5.0

$
0
0
Android
  • Fixed issue in CMakeLists.txt where parenthesis were incorrectly used instead of brackets.
  • Fixed issue in CMakeLists.txt where pplxlinux.cpp source file was missing.
  • Added Android TestRunner packing androidproj to build.

Windows
  • Fixed several code analysis warnings.
  • Updating NuGet package for missing OpenSSL license, also patched 2.4.0's NuGet package.
  • Fixed not working on XP issue because of crypto API. #331, #334
  • Fixed several functions missing an explicit calling convention. This caused problems if you changed the calling convention from the cdecl.
  • Added support for Windows on Devices/Galileo. #217
  • Added option to force using PPLX on Windows Threadpool instead of PPL on the Concurrency Runtime. Library can be rebuilt using CPPREST_FORCE_PPLX macro.
  • Updated all binaries to use whole program optimizations, slightly decreasing binary size and small potential performance improvements.
  • Merged pull request adding support for CMake for Windows desktop.

OSX
  • Merged a pull request to work around a FindOpenSSL.cmake issue, enabling it to find Homebrew's copy.
  • Added support for iOS 64bit simulator. #196

websocket_client
  • Fixed a race condition in Websocket++ based implementation during websocket client destructor which would sometimes result in an AV/Segfault.
  • Added proxy support for Websocket++ based implementation.
  • Added support for Server Name Indication (SNI) to Websocket++ based implementation.
  • Updated server certificate verification to accept SERVER_GATED_CRYPTO and SGC_NETSCAPE usage for Websocket++ based implementation on Windows.

pplx
  • Merged a pull request lazy instantiating the underlying threadpool used. Allows for forking processes in certain circumstances. #68

http_client
  • Make std::function parameter to http_client::add_handler passed by const reference.
  • Fixed invalid check in WinHTTP based implementation causing autologon security level to be high if credentials are not provided.
  • Added extract_utf8string and extract_utf16string to http_request and http_response classes. This allows uses either UTF-8 or UTF-16, instead of utility::string_t, more efficiently regardless of the platform.
  • Implemented native handle API for non-Windows platforms exposing Boost.Asio structures. This allows for configuring additional options like client certificates for example. #168
  • Fixed bug in Boost.Asio based implementation that incorrectly caused multiple handshakes to occur when reusing connections with HTTPS.
  • Fixed bug incorrectly setting the Content-Length header when not using the "C" locale.

json
  • Fixed issue where the JSON library assumes char is a signed type, however C++ doesn't guarantee this. On ARM with Clang for example char is an unsigned type. This lead to incorrect parsing.

Miscellaneous
  • Merged pull request adding http_constants.dat to be installed with 'make install'.
  • Deprecated utility function web::http::bind, this was an implementation detail and really never should have been part of the API.
  • Added overloads that accept a std::locale for utility::conversions::print_string and utility::conversions::scan_string.
  • Fixed several locations where a stringstream was being used and assumed the "C" locale was set.

Tests
  • Fixed race conditions in close_callback_client_from_server
  • Added proper synchronization to test_websocket_server (preventing some race conditions). #305

New Post: the right way to read JSON from a file and POST it

$
0
0
Hi Holger_0000,

Ok I've fixed the problem in the 'development' branch here on CodePlex. The fix will be in our NuGet package at the next release 2.5.0. If you get a chance could you perhaps try building from source in the development branch and make sure you aren't hitting any other issues?

Thanks,
Steve

New Post: monitoring page

$
0
0
I said that I have started to inspire from another application that has something like that. "Monitoring" I have renamed, it was called "Server". But anyway, the idea is that I need a page to verify the state of my application. I want to be able to verify if the application is running or not, and I have thought that if I create a page (or server) at the start of the application that has message (like a json: {"state":"on"}), and like this if someone is accessing the http://x.x.x.x:9000 (for example), it can see if the application is still running or not. I would appreciate your support in this, even if it totally different from the example I have started.

I am on Linux, so I have seen a http_linux_server class, maybe with that, it will be easier?
Viewing all 4845 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>