BoldDesk®Customer service software offering ticketing, live chat, and omnichannel support, starting at $49/mo. for 10 agents. Try it for free.
Hello,
I believe i am experiencing a similar issue to this forum item:
https://www.syncfusion.com/forums/172039/the-following-pop-up-only-seems-to-happen-on-our-live-environment-even-though-we-have-a
I receive the error "Document Reference pointer does not exist in the cache" in our live environments. I am able to resolve this issue by setting the load balancer to stick sessions, which leads me to believe this is a memory cache issue. Unfortunately, it is not feasible to keep the load balancer in 'sticky' mode, and will need a solution to this.
Is there a workaround to this? I am willing to try using redis, as used in the linked forum above, but I would like some assistance on setting this up. Or an alternative, if that is recommended.
Thanks,
Josh
Hi Joshua Rush,
We
have provided a reference sample and documentation to assist you in configuring
the Redis cache and resolving the "Document Reference pointer does not
exist in the cache" error. For optimal performance, we recommend using the
Standalone PDF Viewer, which runs entirely on the client side and delivers
better performance than the server-backed PDF viewer. Please review the sample
and documentation, and feel free to contact us if you need any further
assistance.
Sample link - loadBalancingSample
Documentation link -Load balancing environment in EJ2 ASP.NET MVC PDF Viewer | Syncfusion
Documentation link - Web-service is not listening to error in EJ2 ASP.NET MVC PDF Viewer | Syncfusion
Regards,
Umamageshwari Shanmugam
Awesome, thank you.
Do you have any documentation/tips on setting up a Redis server in AWS Console?
Update: I was able to set up a Redis server in the AWS console. I added the connection string to my project, and I was able to establish a connection to the Redis server. However, I am now getting a new error when the Load function is hit in the controller. This is the response: "Document stream does not exist in the cache" -
Do you know of any rules I need to setup in AWS that could be causing this? Or tips on where to go from here to resolve this issue?
Thanks,
Josh
Hi Joshua Rush,
We
have successfully configured the Redis cache and set up the connection string
in Azure, confirming that the EJ2 PDF Viewer is working as expected in this
environment. Could you clarify which AWS service you are using to host the
Redis server? This information will help us replicate the environment on our
machine to investigate the reported issue. Additionally, please provide more
details about the problem, including the size of the PDF document, a video
demonstrating the issue, and relevant code snippets from the controller file.
These details will help us better understand the request flow, reproduce the
issue, and provide precise assistance.
Regards,
Umamageshwari Shanmugam
We are using an ElastiCache Redis OSS 7.1 service to host the server.
Here is the cluster details:
We have discovered if we do not have multiple web servers running, we do not run into this error. The redis cache is working when 1 web server is present.
Here is the load function and the function that sets up the cache manager. I am ommitting the connectionstring for security reasons, but can confirm I have established a connection to the redis server:
[System.Web.Mvc.HttpPost]
public ActionResult Load(jsonObjects jsonObject)
{
PdfRenderer pdfviewer = new PdfRenderer();
MemoryStream stream = new MemoryStream();
var jsonData = JsonConverter(jsonObject);
var filename = String.Empty;
var requestID = String.Empty;
var pdfName = String.Empty;
object jsonResult = new object();
//cache path - need to figure out if we still use this?
var sfpath = Path.Combine(PDFHelper.GetPDFViewerTempDirectory(), "Syncfusion\\");
if (!Directory.Exists(sfpath))
{
Directory.CreateDirectory(sfpath);
}
if (jsonObject != null && jsonData.ContainsKey("document"))
{
if (bool.Parse(jsonData["isFileName"]))
{
if (jsonData.ContainsKey("requestID"))
{
requestID = jsonData["requestID"];
}
else
{
return this.Content(jsonData["requestID"] + " is not found");
}
if (jsonData.ContainsKey("document"))
{
filename = jsonData["document"];
}
if (!String.IsNullOrWhiteSpace(filename))
{
pdfName = filename + ".pdf";
}
string documentPath = PDFHelper.GetFilePath(requestID, "" + pdfName); //GetDocumentPath(jsonData["document"]);
if (!string.IsNullOrEmpty(documentPath))
{
byte[] bytes = System.IO.File.ReadAllBytes(documentPath);
stream = new MemoryStream(bytes);
}
else
{
return this.Content(jsonData["document"] + " is not found");
}
}
}
PdfLoadedDocument document = new PdfLoadedDocument(stream);
MemoryStream streams = new MemoryStream();
document.Save(streams);
File(streams, "application / pdf", pdfName);
SetCacheManager(pdfviewer);
jsonResult = pdfviewer.Load(stream, jsonData);
return Content(JsonConvert.SerializeObject(jsonResult));
}
private void SetCacheManager(PdfRenderer pdfviewer)
{
try
{
pdfviewer.CacheManager = new PDFCacheManagerController(connectionString, 30);
}
catch (Exception ex)
{
//log the exception and log the file path
Log logger = new Log(typeof(PDFApiViewerController));
logger.logError("Error during SetCacheManager: " + ex.Message, ex);
}
}
This issue is happening when we have PDFs with multiple sections. We have added a menu that allows the user to switch between PDFs in the viewer. Here is the code in our view:
<div id="pdfNavigation" style="background-color:#FFFFFF;width:300px;height:500px;border:3px solid #808080">
<div style="height:35px;margin-bottom:5px;font-weight:bold;font-size:14pt;color:#FFFFFF;background-color:#5C9CCC;padding:5px 5px 5px 10px">
<img src="@Url.Content("~/Content/themes/images/icons-png/recycle-white.png")" style="cursor:pointer" onclick="javascript:location.rel='nofollow' href=location.rel='nofollow' href" />
<span>Sections</span>
</div>
<div style="width:100%; height: calc(100% - 40px); overflow: auto">
<div>
@{
int fileindex = 0;
string selectedClass = "Selected";
foreach (var file in Model.FileInformation.Sections)
{
fileindex = 0;
if (Model.FileInformation.Sections.Count > 1)
{
@:<div style="font-size:12pt;font-weight:bold;line-height:1.7;padding-left:10px;color:#000000;background-color:#C0C0C0;margin-bottom:5px;">@file.Name</div>
}
foreach (var fileinfo in file.Files)
{
@:<div title="@(fileinfo.FormTitle)" class="formLink @selectedClass" style="height:20px;white-space:nowrap;font-size:11pt;padding-left:20px;margin-bottom:5px;cursor:pointer" onclick="javascript:PXEPDFViewer.loadForm(this, '@(file.Name)_@(fileindex.ToString())')">@(fileinfo.FormTitle)</div>
fileindex++;
selectedClass = String.Empty;
}
}
}
</div>
</div>
</div>
<div id="PdfViewer" style="width:100%;height:500px;border:3px solid #808080">
@(Html.EJS().PdfViewer("pdfviewer")
.ToolbarSettings(new Syncfusion.EJ2.PdfViewer.PdfViewerToolbarSettings
{
ShowTooltip = false,
ToolbarItems = "PageNavigationTool, PrintOption, " +
"SelectionTool, SearchOption, MagnificationTool, UndoRedoTool"
})
.EnableCommentPanel(false)
.FormFieldFocusOut("formfieldModified")
.FormFieldClick("formFieldClicked")
.EnableNavigationToolbar(false)
.EnableAnnotationToolbar(false)
.DocumentLoad("docLoad")
.EnableFormDesigner(false)
.EnableAutoComplete(false)
.Render())
</div>
here is the JS function that is hit when they switch between PDFs:
function loadForm(selectedItem, filename) {
$(".formLink").removeClass("Selected");
$(selectedItem).addClass("Selected");
this.filetoload = filename;
if (pdfViewer.isDocumentEdited) {
// Flag the doc as dirty
$("#IsDirty").text("1");
// Save the changes back to original document
pdfViewer.ajaxRequestInitiate = ajaxRequestInitiate;
pdfViewer.serverActionSettings.download = "DownloadSaveFormFile";
pdfViewer.download(false);
pdfViewer.serverActionSettings.download = "Download";
pdfViewer.load(filename);
//$.get(apiURI + "/FileToSave?filename=" + pdfViewer.fileName, function (data) {
// pdfViewer.download(false);
// pdfViewer.load(filename);
//});
return;
}
pdfViewer.load(filename);
}
I will attach a video in another message.
I need to clarify, the "Web Service Not Listening" message and the "Document stream not found in the cache" do not exclusively happen when we have "sections" in the PDFViewer. It happens when we load just 1 PDF with 1 page as well. I misspoke earlier. It just happens more frequently when we have the sections and the user can load multiple PDFs in the viewer. I attached a video to show the issue with a 1 page PDF.
Apologize for the constant stream of messages, but figured it might be beneficial to share some more of our code. I have attached the view and controller in the zip file.
I have some more information that might be useful. I added some logging to the GetCache and AddCache controller actions that are added to the CacheManager controller. These are the log outputs:
2024-11-21 17:18:18,528, ERROR, /LM/W3SVC/1/ROOT/PXEMain-6-133766830137228908, [PartnerXE.Controllers.PDFCacheManagerController], (Agy:(null),Emp:(null),IP:(null),Atom:(null)), (:0), AddCache - set string. key: PDF_INFO3tMmOwVhHx/ABvyLsC3ysQ==: data: 113
System.Exception: Exception of type 'System.Exception' was thrown.
2024-11-21 17:23:58,578, ERROR, /LM/W3SVC/1/ROOT/PXEMain-7-133766834219176675, [PartnerXE.Controllers.PDFCacheManagerController], (Agy:(null),Emp:(null),IP:(null),Atom:(null)), (:0), GetCache - set string. key: PDF_INFO3tMmOwVhHx/ABvyLsC3ysQ==: documentContent: 113
System.Exception: Exception of type 'System.Exception' was thrown.
2024-11-21 17:23:58,740, ERROR, /LM/W3SVC/1/ROOT/PXEMain-7-133766834219176675, [PartnerXE.Controllers.PDFCacheManagerController], (Agy:(null),Emp:(null),IP:(null),Atom:(null)), (:0), GetCache - set string. key: PDF_INFO3tMmOwVhHx/ABvyLsC3ysQ==: documentContent: 113
System.Exception: Exception of type 'System.Exception' was thrown.
2024-11-21 17:23:58,740, ERROR, /LM/W3SVC/1/ROOT/PXEMain-7-133766834219176675, [PartnerXE.Controllers.PDFCacheManagerController], (Agy:(null),Emp:(null),IP:(null),Atom:(null)), (:0), GetCache - set string. key: PDF_CONTENT3tMmOwVhHx/ABvyLsC3ysQ==: documentContent: 0
System.Exception: Exception of type 'System.Exception' was thrown.
2024-11-21 17:23:58,788, ERROR, /LM/W3SVC/1/ROOT/PXEMain-7-133766834219176675, [PartnerXE.Controllers.PDFCacheManagerController], (Agy:(null),Emp:(null),IP:(null),Atom:(null)), (:0), AddCache - set string. key: PDF_INFO3tMmOwVhHx/ABvyLsC3ysQ==: data: 113
System.Exception: Exception of type 'System.Exception' was thrown.
2024-11-21 17:24:00,396, ERROR, /LM/W3SVC/1/ROOT/PXEMain-7-133766834219176675, [PartnerXE.Controllers.PDFCacheManagerController], (Agy:(null),Emp:(null),IP:(null),Atom:(null)), (:0), GetCache - set string. key: PDF_INFO3tMmOwVhHx/ABvyLsC3ysQ==: documentContent: 113
System.Exception: Exception of type 'System.Exception' was thrown.
2024-11-21 17:24:00,396, ERROR, /LM/W3SVC/1/ROOT/PXEMain-7-133766834219176675, [PartnerXE.Controllers.PDFCacheManagerController], (Agy:(null),Emp:(null),IP:(null),Atom:(null)), (:0), GetCache - set string. key: PDF_INFO3tMmOwVhHx/ABvyLsC3ysQ==: documentContent: 113
System.Exception: Exception of type 'System.Exception' was thrown.
2024-11-21 17:24:00,396, ERROR, /LM/W3SVC/1/ROOT/PXEMain-7-133766834219176675, [PartnerXE.Controllers.PDFCacheManagerController], (Agy:(null),Emp:(null),IP:(null),Atom:(null)), (:0), GetCache - set string. key: PDF_CONTENT3tMmOwVhHx/ABvyLsC3ysQ==: documentContent: 0
System.Exception: Exception of type 'System.Exception' was thrown.
2024-11-21 17:24:00,409, ERROR, /LM/W3SVC/1/ROOT/PXEMain-7-133766834219176675, [PartnerXE.Controllers.PDFCacheManagerController], (Agy:(null),Emp:(null),IP:(null),Atom:(null)), (:0), AddCache - set string. key: PDF_INFO3tMmOwVhHx/ABvyLsC3ysQ==: data: 113
As you can see, AddCache is called and used for Key PDF_INFO3tMmOwVhHx/ABvyLsC3ysQ==. Then GetCache is called and it looks for 2 separate Keys, the PDF_INFO3tMmOwVhHx/ABvyLsC3ysQ== key, mentioned already, and then PDF_CONTENT3tMmOwVhHx/ABvyLsC3ysQ==. The PDF_CONTENT key does not look like it was ever passed to the AddCache controller action.
Hi Joshua Rush,
Could you please try
the EJ2 PDF Viewer with Azure Redis Cache? So far, we have only validated the
Redis Cache in the Azure environment. Additionally, we are in the process of
obtaining access to the AWS ElastiCache environment to investigate the reported
issue further.
Could you also provide additional details about the instances where the application is hosted in AWS? This information would help us replicate the environment effectively. Once the AWS setup is complete, we will validate the query and analyze the request flow to provide more precise support.
Regards,
Umamageshwari Shanmugam
We have similar issue at Asp.NET MVC Web farms situation. with one web server, it works fine, but more than one web server, we got error: "Document stream does not exist in the cache" when RenderPdfPages called.
".
Hi Lijun Jinang,
Thank you for the
update. Please confirm whether you have integrated the Redis cache into the
service to resolve this issue. We have provided documentation on adding Redis
cache to the service below. Additionally, we recommend using the standalone PDF
Viewer component, which does not require a service to render PDFs. For your
reference, we have also included documentation on the standalone PDF Viewer
component.
Documentation
on standalone PDF Viewer
Documentation
on applying Redis cache
Regards,
Sathiyaseelan K