Chrome Network Error - Downloading PDF - javascript

In our application, we have a users downloading PDF through a AJAX call -- basically we have a table listing a lot of PDF files and when the user clicks on a filename, an AJAX call is made to a Servlet which serves the file as reponse.
The Content-Length is set for the response along with other required params (Content-Disposition, Content-Type etc). We have observed that for a specific set of users, the download fails with a Network Error. The download is initially initiated and begins but after some time the download just stops processing and this error is thrown. This has been the behavior with both IE and Chrome.
Initially, the content-length was not provided and hence defaulted to chunked transfer but this has been changed now. Even with chunked transfer we did have the same issue.
We have run through the steps provided in Chrome documentation (clearing cookies etc) but there has been no respite. We did run through the net-exports feature in Chrome and they have the following as the last few lines as -
t=237104 [st=161960] DOWNLOAD_ITEM_INTERRUPTED
--> bytes_so_far = "0"
--> interrupt_reason = "NETWORK_FAILED"
t=237104 [st=161960] -DOWNLOAD_ITEM_ACTIVE
The users who are unable to download are able to download PDF from other sites. If we host a static PDF in our site, the users are able to access it as well.
Any pointers on what would need to be our next lookout?
(The users connect to a web server Apache HTTPD)
Thanks,
Aravind

I had the Network Error issue while downloading the PDF files from Jasper.
I followed the below steps to fix the downloading issue with the Chrome.
Enter the chrome://settings/content/pdfDocuments?search=pdf into the
address bar of the Chrome.
Turn ON the option "Download PDF files instead of automatically opening them in Chrome"

Change PDF MIME Type in Web Server or Response Headers from application/pdf to application/octet-stream
This problem is when is enabled gzip compression and/or HTTP/2
Enable http/2 for SSL connections is a hugely valuable performance setting. However http2 expects the reported size to match what the webserver reports for streamed content.
The problem occurs in Cloudflare to.

Related

To install Chrome Extension locally

I want to put Chrome Extension on my personal server and download and install it through a browser. However, if you receive and download crx as a response from the server, the error crx_required_proof_missing occurs. Is it impossible to put it on a personal server and proceed?
I created a crx file according to the document, uploaded it to the node server, received it from the browser, and proceeded with the download.
Chrome 75 has introduced some changes, where if an extension is downloaded using a direct URL, then it tries to be smart and figure its metadata which then contains the type which says that it's an extension and Chrome tries to install it immediately - which fails for custom extensions which are not in the Chrome Extension store.
So, if a CRX file is downloaded directly, Chrome figures out the file's content-type to be 'application/x-chrome-extension' which then triggers the auto-installation (and fails for custom extensions).
But if the same file is downloaded indirectly from a website, the website (in our case) sets the file's content-type to `application/octet-stream' which is a generic one and Chrome doesn't try to auto-install it.
So first make sure that the content-type with which your server offer the file is application/x-chrome-extension

Processing TIFF Attachments in RingCentral using NodeJS

I have a program written in Node using the "RingCentral" package, the program downloads faxes sent to a RingCentral account. When the faxes are in PDF format everything works correctly, however if the fax attachment happens to be a TIFF image (only very few are) the data returned seems to be incomplete, it is always 390 bytes. Inspecting the file shows that it is indeed the TIFF image (starts with II*).
Has anyone come across this issue? Is there a way to force all faxes to be stored as PDF by RingCentral?
Thanks,
-Carlos
RingCentral supports storing faxes as PDF and TIFF files. The configuration preference is available per extension. Upon retrieval, the Content-Type HTTP response header will be set to application/pdf or image/tiff
You could check to see if the response header has "Content-Type" : 'image/tiff', so as to save the attachment as .tiff file format when you retrieve the faxes via the message-store endpoint :
GET /account/~/extension/~/message-store
For more information you could refer to our RingCentral-Fax-FAQ
For any support related issues, please open a case with our developer support at :
Portal : https://developer.ringcentral.com/support.html
Email : devsupport#ringcentral ( with the necessary details )
After rerunning my test again I realized these faxes are also having problems through the web interface, so the attachment must be corrupted for some reason.
Glad you found your issue and it was due to actual corrupted faxes in the comment thread. For others that come across this, here's some information on how to test TIFF files.
if the fax attachment happens to be a TIFF image (only very few are) the data returned seems to be incomplete, it is always 390 bytes[...] Has anyone come across this issue?
Downloading TIFF images works fine for me using the RingCentral API. I used the fax_download.rb script in the community Ruby SDK. I used the fax_send.rb demo script to send the test_file.pdf included in the SDK to an extension configured for TIFF files and was able to download and read it as a 14538 byte TIFF file using the fax_download.rb script.
Resource links:
Ruby SDK
fax_send.rb
fax_download.rb
test_file.pdf
Is there a way to force all faxes to be stored as PDF by RingCentral?
There is a file type configuration setting for PDF and TIFF per extension as mentioned by #CarpeDiem above. Having all extensions configured for PDF would ensure all stored faxes were in PDF format. This can be set by RingCentral support on the backend, but I'm not sure if there is a customer facing setting.

How to identify javascript cross domain policy error

I am looking for a method that helps quickly identify if a js form error is related to cross domain policy mecanism. If possible this method needs to be done from remote connection, as I do not have access to production server and everything is working fine in local sandbox and staging server. The issue only comes up on production server.
This occurs on a drupal webform that has a file upload field, used for an image upload. Ie8 and Ie9 fail to upload, the throbber runs indefinetely and a js ajax message is returned and interpreted as a downloable file. The file contains the ajax response.
I am by no means a js guru and this one has me stumped. How would one identify / troubleshoot this issue?

how to open csv file in IE in by javascript

In my asp page, I have to open a csv file in IE by java script. The code which I am using is as below:
csvWindow = window.open("/com/csv/"+csvFileName, "datacsv", "toolbar=yes,location=no,directories=yes,status=no,menubar=yes,scrollbars=yes,resizable=yes,width=790,height=450,screenX=50,screenY=25,left=50,top=25");
Code is running in IIS server.
When I run this code and open csv file it gives below message
Microsoft Office Excel cannot access the file
"http://192.168.3.228:107/com/csv/CSV_file_1345728.csv". There are several possible reasons:
The file name or path does not exist
the file is being used by another program
the workbook you are trying yo save has the same name as a currently open workbook.
But file is being created.So path is correct and i think that file is also not used by another program
Please help me what should I do
The problem is that when Excel is opened it will attempt to fetch the CSV file itself, this a change in behaviour in office apps since 2007. However since Excel runs in a different process it will not send any cookies that would have been generated during the logon. When the website receives the request it will respond with a 401 status.
There are no easy solutions that I know of with entirely satisfactory results. Here are a number of solutions but all have drawbacks.
Make the authentication cookie persistent, this will allow Offices apps to pick up and send the cookie. The down side being the user remains persistently logged even after a client machine reboot (much like how Stackoverflow appears to work).
Use a standard HTTP authentication protocol like "Basic" or "Negotiate". The down side is that this will cause Excel to display a logon box and the user has to logon again. One exception to this drawback is using "Negotiate" or "NTLM" against an IIS box where the site is registered as part of the IE's Intranet Zone, in which case the HTTP stack used by excel will attempt to use the current user credentials.
Have a server side script that can run anonymously send the csv file and include in the URL some unique ID (such as GUID) which is a one off grant of access. Much more complex to set up.
If you want to open the file with MS Excel, you could try not to serve the file directly, but write an ASP page with Content-Type=application/force-download, the real file name ending with .css and the actual file content. In this case, MSIE will first download the file to the local disk cache and then will feed it to MS Excel.
If you just want to show the CSV text in the browser window, maybe the best is to change its extension or to make some proxy page with Content-Type=text/plain and no mention of CSV at all. The association CSV/Excel seems to be hardcoded in MSIE.

Why isn't a JS file hosted on Amazon S3 getting cached by the browser?

I have a JS file hosted on Amazon S3 (http://s3.amazonaws.com/wingify/vis_opt.js). I want the file to be cached on users' browsers so that they don't have to download it with every page view. However, in spite of setting Cache Control header I don't think it is getting cached. Browser still contacts Amazon Server with every pageview.
Here is the example of page where this script is embedded: http://myjugaad.in/
If you have Firebug, you will be able to see that browser requests it with every pageview.
What can I do so that the file gets permanently cached? Thanks for help.
You need to set the Cache-Control header when upload your files.
This tells your browser how long it can cache the file for.

Categories

Resources