
Hi,
I'm using the asynchronous process without success using this source code :
void MyServer::forwardRequest(HTTPRequestPtr& request, TCPConnectionPtr& tcp_conn) {
// make sure it will get closed when finished
tcp_conn->setLifecycle(TCPConnection::LIFECYCLE_CLOSE);
// forward request
TCPConnectionPtr tcp_conn_fw(new TCPConnection(getIOService()));
tcp_conn_fw->setLifecycle(TCPConnection::LIFECYCLE_KEEPALIVE);
boost::system::error_code error_code;
error_code = tcp_conn_fw->connect(boost::asio::ip::address::from_string(getFwAddress()), getFwPort());
if (!error_code) {
HTTPRequestWriterPtr writer(HTTPRequestWriter::create(tcp_conn_fw, request,
boost::bind(&MyServer::readResponse,
this, tcp_conn_fw, request, tcp_conn)));
writer->send();
}
}
/**
* reads in a HTTP response asynchronously
*/
void MyServer::readResponse(TCPConnectionPtr& tcp_conn_fw, HTTPRequestPtr& request, TCPConnectionPtr& tcp_conn) {
HTTPResponseReaderPtr reader(HTTPResponseReader::create(tcp_conn_fw, *request,
boost::bind(&MyServer::sendResponse,
this, _1, _2, request, tcp_conn)));
reader->receive();
}
The object never get the response from the target server even if this one receives the request and answer with a server error message. The "readResponse" method is never reached. I write this code based on the WebServerTest.cpp. What's going wrong?
Thanks

Discounted UK Tiffany Jewellery Sale Outlet provides designer Tiffany Ring, necklaces and other jewelry in wholesale price. UK Tiffany specializes in Tiffany jewellery Tiffany Bracelets Tiffany Earrings Tiffany and co We have all kinds of Tiffany Jewellery, such as Tiffany Necklaces, Tiffany Rings Tiffany Necklaces Tiffany Rings tiffany jewelry Choose, buy and shop for on sale tiffany jewelry including Tiffany & Co Silver Necklace, Pendants, Bangles, Bracelets, Earrings, Rings and Accessories. tiffany co tiffany and co UK Tiffany Jewellery Sale Outlet provides designer Tiffany Ring, necklaces and other jewelry in wholesale price. UK Tiffany specializes in Tiffany jewellery
- Login or register to post comments
Submitted by dawei (not verified) on Tue, 07/27/2010 - 19:02.I simply miss to run the i/o scheduler. :-(
It works great now. :-)
- Login or register to post comments
Submitted by ruddy32 on Thu, 06/25/2009 - 23:31.Forgive me if this seems like a silly question, but are you sure the call to connect() succeeds? If it were to fail then the HTTPRequestWriter would never be created.. Also, you might want to confirm that the destination server (getFwAddress()) is receiving the forwarded request and sending a reply to it.
- Login or register to post comments
Submitted by Mike Dickey on Thu, 06/25/2009 - 08:43.I have try another process used in "WebServerTest" for asynchronous transfert without success. The bind HTTPRequestWriter method is not called.
class HTTPProxy
...
{
...
public:
...
void send(pion::net::HTTPRequestPtr& request) {
...
pion::net::HTTPRequestWriterPtr writer(
pion::net::HTTPRequestWriter::create(tcp_conn, request,
boost::bind(&HTTPProxy::readResponse, this, tcp_conn, request)));
...
}
void readResponse(pion::net::TCPConnectionPtr& tcp_conn,
pion::net::HTTPRequestPtr& request) {
...
}
...
}
This process is called while the system handles a request. What's going wrong?
- Login or register to post comments
Submitted by ruddy32 on Thu, 06/25/2009 - 01:39.