Project

General

Profile

Bug #7295

WFileUpload is nearly always unresponsive when app is linked to wtfcgi

Added by S ET almost 2 years ago. Updated almost 2 years ago.

Status:
New
Priority:
Low
Assignee:
-
Target version:
-
Start date:
10/22/2019
Due date:
% Done:

0%

Estimated time:

Description

I found that WFileUpload very rarely works when app is linked to wtfcgi, perhaps one in ten times. When it does, it would upload a file after 30 to 120 seconds. Uploading is immediate when linked with wthttp. App is served by Apache on Linux, with a virtual host config, on an ARM 32 bit platform. The code below is my quick-and-dirty testing app.

Can you please advise how to resolve this ? Thanks.

// cat main.cpp
#include <cstdlib>
#include "TestAppMain.h"
#include <Wt/WApplication.h>
#include <Wt/WEnvironment.h>

using namespace std;
using namespace Wt;

unique_ptr<WApplication> createApplication(const WEnvironment& env)
{
    unique_ptr<TestAppMain> app = cpp14::make_unique<TestAppMain>(env);
    return (app);
}

int main(int argc, char** argv) {

    return WRun(argc, argv, &createApplication);
}

// cat TestAppMain.h
#ifndef TESTAPPMAIN_H
#define TESTAPPMAIN_H

#include <Wt/WApplication.h>
#include <Wt/WEnvironment.h>
#include <Wt/WFileUpload.h>
#include <Wt/WTextArea.h>
#include <Wt/WPushButton.h>

using namespace Wt;

class TestAppMain : public WApplication {
public:
    TestAppMain(const WEnvironment& env);
    virtual ~TestAppMain();
private:
    WFileUpload * m_upload;
    WTextArea * m_tarAny;
    WPushButton * m_btnUpload;

    void OnUploaded();
    void OnFileTooLarge();
    void OnDataReceived(::uint64_t bIn, ::uint64_t total);
};

#endif /* TESTAPPMAIN_H */

// cat TestAppMain.cpp
#include "TestAppMain.h"
#include <Wt/WContainerWidget.h>
#include <Wt/WBreak.h>

using namespace std;

TestAppMain::TestAppMain(const WEnvironment& env)
: WApplication(env)
{
    WApplication::setTitle("TEST");
    m_tarAny = new WTextArea("Test\n");
    m_tarAny->setWidth(300);
    m_tarAny->setHeight(350);
    root()->addWidget(unique_ptr<WTextArea> (m_tarAny));
    root()->addWidget(cpp14::make_unique<WBreak>());
    m_upload = new WFileUpload();
    root()->addWidget(unique_ptr<WFileUpload> (m_upload));
    m_btnUpload = new WPushButton("DoUpload");
    root()->addWidget(unique_ptr<WPushButton> (m_btnUpload));

    m_upload->uploaded().connect(this, &TestAppMain::OnUploaded);
    m_upload->fileTooLarge().connect(this, &TestAppMain::OnFileTooLarge);
    m_upload->dataReceived().connect(this, &TestAppMain::OnDataReceived);
    m_btnUpload->clicked().connect(m_upload, &WFileUpload::upload);
}

TestAppMain::~TestAppMain()
{
}

void TestAppMain::OnUploaded()
{
    m_tarAny->setText(m_tarAny->text()
            + m_upload->spoolFileName() + WString("\n"));
}

void TestAppMain::OnFileTooLarge()
{
    m_tarAny->setText(m_tarAny->text() + WString("File too large\n"));
}

void TestAppMain::OnDataReceived(::uint64_t bIn, ::uint64_t total)
{
    m_tarAny->setText(m_tarAny->text()
            + to_string(bIn) + WString("/") 
            + to_string(total) + WString("\n"));
}
#1

Updated by Roel Standaert almost 2 years ago

File uploads should work with wtfcgi, so this could be a regression.

Note: since Apache will actually first receive the entire request and then pass it on through FastCGI, you actually can't get any upload progress. Progress updates do work with wthttp. We normally recommend that you use wthttp with an HTTP proxy (for Apache, mod_proxy_http) for deployment.

#2

Updated by S ET almost 2 years ago

>We normally recommend that you use wthttp with an HTTP proxy

I have well understood your recommendation, I just discovered it's possible and understood it's working principle, I'll dig into that ASAP. For now, I'm stuck with wtfcgi. In any case, the app requiring file upload is not yet finalized.

My concern with wthttp behind a proxy would be about client X509 certificates.

A wtfcgi linked app gets client certificates data if "SSLOptions +StdEnvVars +ExportCertData" is used in the vhost config.

Will the wthttp linked app behind a proxy receive client X509 certificates ? Directly ? Or by using SSLOptions mentioned above ? I know how to launch a wthttp linked app for client authentication, I do that during development when I access the app instance directly :8080.

Thanks.

#3

Updated by Roel Standaert almost 2 years ago

My concern with wthttp behind a proxy would be about client X509 certificates.

That's a good point. We do have support for receiving these client certificates through a header (for dedicated session processes), but it seems like there is no standard way to do it. The way we do it is specific to Wt.

#4

Updated by S ET almost 2 years ago

I switched from mod_fastcgi used above, to mod_fcgid, and uploading files is done instantly. So it's related to the CGI engine.

As a caveat, the UI is completely borked, no theming/styling. The resources directory is rightly set, tried it in different locations, with no satisfactory result. That's another problem, will try to resolve it.

Thanks for your assistance.

#5

Updated by Roel Standaert almost 2 years ago

I saw the same issues, but I was using mod_proxy_fcgi and fcgistarter.

#6

Updated by Roel Standaert almost 2 years ago

When I say same issue, I mean this issue (#7295). The broken resources seems strange. In the network tab of the developer tools of the browser you can see where it's trying to get wt.css etc. from.

#7

Updated by S ET almost 2 years ago

Just rebuilt Wt after after a 'git pull'. With mod_fcgid, the layout is now done with theming, and upload starts right away.

Thanks.

[P.S : By the way, I could successfully try a setup behind a reverse proxy. This is not fitting however when client certificates must be passed to the application.]

#8

Updated by S ET almost 2 years ago

Ha ! After restarting Apache, the layout is bad again with mod_fcgid !!! I think it's time for me to give up.

Also available in: Atom PDF