Can't upload post attachments

Get help with installation and running phpBB 3.2.x here. Please do not post bug reports, feature requests, or extension related questions here.
Kyudos
Registered User
Posts: 42
Joined: Fri Mar 25, 2011 2:37 am

Re: Can't upload post attachments

Post by Kyudos » Tue Sep 03, 2019 1:22 am

I'm not very familiar with PHP, so I'll have to research the debug angle a bit.

However, I do note that all the stalled attachment uploads are cut off at exactly 5119bytes (4.99KB). This seems very deliberate, but I can't find anything PHP, BB or IIS related that might account for that.

User avatar
EA117
Registered User
Posts: 839
Joined: Wed Aug 15, 2018 3:23 am
Contact:

Re: Can't upload post attachments

Post by EA117 » Tue Sep 03, 2019 2:02 am

Kyudos wrote:
Tue Sep 03, 2019 1:22 am
However, I do note that all the stalled attachment uploads are cut off at exactly 5119bytes (4.99KB). This seems very deliberate, but I can't find anything PHP, BB or IIS related that might account for that.
Are you saying that when uploading a >5KB file (e.g. 100KB or more), you end up with an incomplete file in the /files folder which is only 4.99KB?

Or are you actually saying that the upload will be rejected (and no incomplete file will be created), unless you attempt to upload a file which is exactly 4.99KB or smaller?

If it's the former (during a >100KB upload, an incomplete 4.99KB file gets created), that certainly does sound at least consistent with a file system-imposed file limitation. Not that it can't be imposed by something else; e.g. malware protection installed on the server, software intentionally designed to filter and block file system access. If you haven't already, maybe make sure the Windows Application or System event log isn't getting reports during these failed upload attempts. (i.e. Not the web server, but Windows Server itself.)

If it is the situation of "during a >100KB upload, an incomplete 4.99KB file gets created", this actually already answers the question of "does the failed POST attempt actually make it to posting.php?" Because if 5KB worth of the file did get created, it's expected that posting.php is the one who did that.

I see that Microsoft's IIS does have its own configuration for maximum upload size; the maxAllowedContentLength setting in the web.config. But we would be expecting an HTTP response if the POST was being rejected for that reason, same as we would expect when it's rejected for one of the PHP-configured limits. Still, if you didn't already, you might want to review the IIS-specific settings, in addition to the PHP-specific settings you've already been looking at.

The fact that you're getting "no response back to the web browser client at all" (until the connection itself times out 600 seconds later) seems like the biggest and most unusual clue. Like the root cause isn't something as simple as an "upload limit" or "file size creation limit" which would have simply immediately returned a failure response. Something that fits better with "no response at all" could be some anti-malware software that isn't taking into account that the file access is happening on an IIS service process, and is "prompting for quarantine" or similar; which is why processing is simply stalled waiting rather than failing. I'm just saying that kind of thing would fit with the "no response at all"; but certainly there are other things that can probably cause that same symptom.

Kyudos
Registered User
Posts: 42
Joined: Fri Mar 25, 2011 2:37 am

Re: Can't upload post attachments

Post by Kyudos » Tue Sep 03, 2019 3:08 am

Yes, the upload starts, the file gets created and (seemingly) 4.99KB gets uploaded, then it stops. If I'm uploading a PNG (for example), I can see the PNG headers in the file. I can rename it from TMP to PNG and see a partial image file. Aa long as the file is less than 5KB the upload completes as it is supposed to and the 'Place Inline' button appears in phpBB. But if it's bigger I end up with TMP file fragments, all the same size.

I've checked our security software (Sophos), no unusual messages. I've checked all the IIS file size limits I can Google up - they are all already much larger than 5KB. I have 'debug' turned on in phpBB, in PHP itself...nothing seems to want to give me any hint!

So I might have to delve into the php code itself and try and but a few debug statements in, but I'm not that hopeful that that will show me anything I don't already know - i.e., the upload starts, but never finishes.

User avatar
Lumpy Burgertushie
Registered User
Posts: 66597
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: Can't upload post attachments

Post by Lumpy Burgertushie » Tue Sep 03, 2019 3:15 am

just a wild guess but are you out of disk space on the web server?


robert
I'm baaaaaccckkkk. still doing work on donation basis. PM your needs.

Premium phpBB 3.2 Styles by PlanetStyles.net

If a tree falls in the forest and nobody is there, does it make a sound?

Kyudos
Registered User
Posts: 42
Joined: Fri Mar 25, 2011 2:37 am

Re: Can't upload post attachments

Post by Kyudos » Tue Sep 03, 2019 3:17 am

Lumpy Burgertushie wrote:
Tue Sep 03, 2019 3:15 am
just a wild guess but are you out of disk space on the web server?
Nope - plenty of GBs free.

User avatar
EA117
Registered User
Posts: 839
Joined: Wed Aug 15, 2018 3:23 am
Contact:

Re: Can't upload post attachments

Post by EA117 » Tue Sep 03, 2019 4:18 am

Kyudos wrote:
Tue Sep 03, 2019 3:08 am
Yes, the upload starts, the file gets created and (seemingly) 4.99KB gets uploaded...
One additional angle we could try with that is using Microsoft's Process Monitor. Nothing fancy you have to install or do; just download and extract to a folder on the Windows Server's desktop, run ProcMon.exe with elevation if it prompts for it, and then duplicate the issue by trying to upload from a remote browser.

Once duplicated, use the File menu to save the log in its native .PML format. If you want to PM me a URL where I can download that .PML file from you, I'm happy to take a look. Or you can filter that log yourself to the htdocs or phpbb application path, and see if you find any clues in the kind of error status that might be occurring after the ~5KB is written.

The 5KB must be a clue; we just don't know to what yet.

Kyudos
Registered User
Posts: 42
Joined: Fri Mar 25, 2011 2:37 am

Re: Can't upload post attachments

Post by Kyudos » Wed Sep 04, 2019 2:05 am

I tried ProcMon. It shows php-cgi.exe WriteFile where 5119 bytes are written then a bunch of UDP send/receives between my machine and a svchost.exe process on the server. Presumably this is the traffic that is keeping the connection alive (until timeout), but no more data is being transferred.

Kyudos
Registered User
Posts: 42
Joined: Fri Mar 25, 2011 2:37 am

Re: Can't upload post attachments

Post by Kyudos » Wed Sep 04, 2019 3:35 am

I just added a temporary test folder to my phpBB3 tree on the web server. I added a simple PHP upload form. With the appropriate permissions, I can upload images to (below) that folder - so is it somehow related to the phpBB3 code?

User avatar
EA117
Registered User
Posts: 839
Joined: Wed Aug 15, 2018 3:23 am
Contact:

Re: Can't upload post attachments

Post by EA117 » Wed Sep 04, 2019 3:52 am

Kyudos wrote:
Wed Sep 04, 2019 2:05 am
I tried ProcMon. It shows php-cgi.exe WriteFile where 5119 bytes are written then a bunch of UDP send/receives between my machine and a svchost.exe process on the server. Presumably this is the traffic that is keeping the connection alive (until timeout), but no more data is being transferred.
WriteFile for 5119 bytes which was successful, but then no further file operations which might have been successful or unsuccessful? We're looking for any subtle or not-so-subtle reasons why the PHP process might have been "forced" to stop writing, as opposed to the PHP process having "chosen" to stop writing. Or for that matter, maybe even a registry setting that might have been read around that time, etc. Or any other clue for why more wasn't written, and/or whether the PHP-CGI.EXE process or IIS request process might have crashed or failed.

Since we don't know what the root cause is, I can't say exactly what you're looking for. I'd still be willing to take a look too, if you want an additional opinion. A URL by PM is probably still best, since there is at least a chance for something sensitive to be unintentionally revealed in the Process Monitor log.
Kyudos wrote:
Wed Sep 04, 2019 3:35 am
I just added a temporary test folder to my phpBB3 tree on the web server. I added a simple PHP upload form. With the appropriate permissions, I can upload images to (below) that folder - so is it somehow related to the phpBB3 code?
Technically doesn't rule out the "NTFS quota on the phpBB /files directory" angle, since you're not trying to upload where phpBB is actually trying to upload. But it certainly helps move in the direction of "it's not a fundamental configuration locked down about this IIS server" and similar. Perhaps try uploading exactly the same file as is failing to upload through phpBB, and into exactly the same /files directory but using your test script.

If that worked, then its much more assured "plupload nor phpBB should be encountering a PHP or file system limit here." That doesn't exactly help "pinpoint" the cause, but does rule out those external possibilities.

Kyudos
Registered User
Posts: 42
Joined: Fri Mar 25, 2011 2:37 am

Re: Can't upload post attachments

Post by Kyudos » Wed Sep 04, 2019 10:28 pm

I modified my simple upload form to upload directly to the phpBB/files folder and it works fine. This has me leaning toward the way phpBB does uploads being the root cause.

Normally, PHP uploads to its temp upload folder, and phpBB copies that tmp file to /files, whilst renaming it with a GUID for the phpBB database. Obviously some DB updates must happen around here too. Do you know if this is synchronous or asynchronous with the upload? I mean, does phpBB wait for the upload to finish before trying to do any of the other stuff(e.g., guid generation, DB updating etc.)

Kyudos
Registered User
Posts: 42
Joined: Fri Mar 25, 2011 2:37 am

Re: Can't upload post attachments

Post by Kyudos » Wed Sep 04, 2019 11:14 pm

Not that its adding much that we can't already see, but the code executes through plupload.js:

phpbb.plupload.uploader.bind('FilesAdded', function(up, files)

but never gets to

phpbb.plupload.uploader.bind('FileUploaded', function(up, file, response)

So what exactly happens after up.start(); ??

User avatar
3Di
Former Team Member
Posts: 14088
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: Can't upload post attachments

Post by 3Di » Wed Sep 04, 2019 11:42 pm

If you think you discovered a bug, your best bet is to get feedback from the developers.

Suggesting to open a ticket at the tracker and wait for a response.

https://tracker.phpbb.com/secure/Dashboard.jspa
Please PM me only to request paid works. Thx.
Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user
Extensions, Scripts, MOD porting, Update/Upgrades
👨‍🏫 | Take a tour to | The Studio | 👨‍🏫

User avatar
EA117
Registered User
Posts: 839
Joined: Wed Aug 15, 2018 3:23 am
Contact:

Re: Can't upload post attachments

Post by EA117 » Thu Sep 05, 2019 1:03 am

At it's core, posting.php expects the file content to be uploaded as a simple form POST request. Upon receipt of the POST, phpBB code will evaluate whether the upload should be accepted, and do all the work to create the attachment information in the database and /files directory. And that's exactly how older (circa phpBB 3.0.x I believe) worked.

To improve the behavior, now the plupload layer is added "between the web browser and phpBB" essentially. Such that now behaviors such as "you can't upload files over a certain size" or "you can't upload files of this type" are rejected by client side plupload code without any submit required. And so the actual "Attach" action happens instantly, but the associated file upload and/or resize operation happens progressively in the background via one or more AJAX operations. And so the actual file transfer can be done in "chunks", such that even if your PHP max_post_size would otherwise prevent attaching a 100MB file, plupload can transfer that 100MB file in chunks that stay within the PHP limit. To then be reassembled at the server before the completed 100MB file is then handed off for normal phpBB posting.php processing.

But "reassembly" is not in play here, because the plupload chunk_size on your server is 500KB. So both files under 5KB and files well over 5KB (up to 500KB in size) are still being transferred in a single POST operation / single AJAX operation. (Still through plupload, because of all the other features besides "chunking" that plupload provides.)

Yes, the issue could definitely be in the server-side plupload-related code. Which is what's accepting the file data, and then making a JSON response back to the client-side plupload code to indicate the plupload operation status. This JSON response (nor any HTTP-level response) is what we're never seeing in your case, in addition to the abandoned 5KB of file content.

The glaring question that raises, of course, is "if the issue is with the phpBB code and/or phpBB-delivered plupload code, why are we currently seeing this only on your server, and not in multiple reports from many phpBB users?" So we still can't rule out that the root cause is ultimately unique to this server, even if we may need to follow into the phpBB and/or plupload code in order to understand what that root cause actually is.

The success response we're expecting comes out of parse_attachments() in /includes/message_parser.php. (The $json_response->send(array('data' => $this->attachment_data, 'download_url' => $download_url)) you see in that function.) So for following the code, I would start there and work backwards to see how close to there execution gets out of posting.php.

Personally, I'm still of the opinion that Process Monitor could be equally or more revealing, knowing what we know right now. Because we know 100% of the file upload data was transmitted across the wire (not a case of the web server saying "stop!" after only 5KB was transmitted) -- plus the fact "no HTTP response at all" ever happens, as though the process is hung or abnormally terminated -- just makes it feel like there could still be big clues around the processing that was going on when the process decided to stop writing after 5KB.

Kyudos
Registered User
Posts: 42
Joined: Fri Mar 25, 2011 2:37 am

Re: Can't upload post attachments

Post by Kyudos » Thu Sep 05, 2019 1:39 am

Some further info - if I add multipart: false, to the plupload config in plupload.html, the problem upload immediately returns with a warning triangle ("Error parsing server response"). So perhaps my server is objecting in some way to a multi-part upload.

Should I have multipart/form-data defined in the sever MIME types? And if so, what extension?

User avatar
EA117
Registered User
Posts: 839
Joined: Wed Aug 15, 2018 3:23 am
Contact:

Re: Can't upload post attachments

Post by EA117 » Thu Sep 05, 2019 3:54 am

Kyudos wrote:
Thu Sep 05, 2019 1:39 am
Should I have multipart/form-data defined in the sever MIME types? And if so, what extension?
I don't see in my Apache config where this long-standing form encoding type needed to be explicitly enabled, but I can't speak for IIS. I do see where Microsoft says they've broken it before, at https://forums.iis.net/t/1229356.aspx.

Although realize you just disabled the multipart/form-data upload with that change, and got the immediate error. i.e. The server immediately sent a "don't like it" response when you didn't use multipart/form-data. Looking at the plupload code, it tries to send as application/octet-stream when the multipart:false is set. You could LAN trace or check your IIS access log to see what HTTP response was given when it attempted to POST as application/octet-stream. But I'm not thinking that multipart/form-data is really unexpected here.

What was the form type sent by your test script that successfully uploaded files? If that was multipart/form-data too and successful, then perhaps that could just rule this angle out, without you needing to chase what multipart/form-data configurations might exist in IIS.

Post Reply

Return to “[3.2.x] Support Forum”