Intermittent Failure to Load Documents

We’ve been experiencing an intermittent failure to load documents accompanied by the error message below:


TB DynamicConfig failed to load in 4000 ms TB.min.js:32
event.returnValue is deprecated. Please use the standard event.preventDefault() instead.
Uncaught ReferenceError: handleRebootOrRefresh is not defined ?sessionId=1_MX40NDM5MDc0Mn5-V2VkIEphbiAyMiAwNjo0Mjo0NCBQU1QgMjAxNH4wLjY1ODk3Njl-&token=T1==cGFydG5…:322
18
Uncaught TypeError: Cannot call method ‘find’ of null apps.groupdocs.com/
[Wed Jan 22 2014 09:46:34 GMT-0500 (EST)]
[Wed Jan 22 2014 09:46:49 GMT-0500 (EST)]
2
Uncaught TypeError: Cannot call method ‘width’ of undefined apps.groupdocs.com/
[Wed Jan 22 2014 09:47:12 GMT-0500 (EST)]
2
Uncaught TypeError: Cannot call method ‘width’ of undefined apps.groupdocs.com
Failed to load resource: the server responded with a status of 404 (Not Found)

Hi todd1 we are sorry that you faced with such difficulties. Can you please provide some more info specifically what are you tried to do download or upload document, also which api do you use PHP or JavaScript, from this error message I see that this is JavaScript error rather than PHP error. Looks like some Web resource is not found:

Failed to load resource: the server responded with a status of 404 (Not Found)


Also if it is possible can you please share your code.
Based on the received information we will reproduce your error and will help you to fix it.



Its probably easiest just to give you access to our development server, and show you the relevant files (1 generates the URL, the other displays the document in an iframe.


Is there a private email address where I can send the instructions?

The beginning of the error message is:


TB DynamicConfig failed to load in 4000 ms TB.min.js:32
event.returnValue is deprecated. Please use the standard event.preventDefault() instead.

which seems to us to be an error with the API. The 404 that happens later is because of the earlier error.

This is the code that generates the groupdocs URL, which we show in an iFrame on a different page:

<?php
/**
* Bootstrap
*/
require("wp-config.php");
session_start();
require("src/APIClient.php");
ini_set('display_errors',1);
error_reporting(E_ALL);
global $wpdb;

$sessionId = $_GET['sessionId'];
$uuid2 = null;

//groupdocs API keys

$table_name = 'wp_groupdocs_users';

//get URL variables
$first_name = $_GET['first_name'];
$last_name = $_GET['last_name'];
$email = $_GET['email'];

//get user or invitee name from depositions or join page
if(!isset($first_name) || !isset($last_name) || !isset($email)){
?> <?
}

else {


//upload new document to GroupDocs & return iframe URL
if(isset($_POST['uploadfile'])&&($_POST['uploadfile'] == 'Display Document')){

//create iframe URL
$uploads_dir = '/var/www/uploads/';
$tmp_name = $_FILES["uploadedfile"]["tmp_name"];
if($tmp_name) {
$name = $_FILES["uploadedfile"]["name"];
$fs = FileStream::fromFile($tmp_name);
$signer = new GroupDocsRequestSigner($privateKey);
$apiClient = new APIClient($signer);
$mgmtApi = new MgmtApi($apiClient);
$api = new StorageApi($apiClient);
$result = $api->Upload($clientId, $name, 'uploaded', null, $fs);
$uuid2 = $result->result->guid;
$basePath = 'https://api.groupdocs.com/v2.0';
$url = "https://apps.groupdocs.com/document-annotation/embed/".$uuid2;
$signature = explode("=", $url);
$sql="update wp_depositions set uuid='$uuid2' where sessionId='$sessionId'";
mysql_connect(DB_HOST,DB_USER,DB_PASSWORD);
mysql_select_db(DB_NAME);
mysql_query($sql);
//If user does not exist in Groupdocs, create them
$user_guid = $wpdb->get_row("SELECT guid FROM ".$table_name." WHERE email = '".$email."'");

if($user_guid == NULL){
//Create User info object
$user = new UserInfo();
//Create Role info object
$role = new RoleInfo();
//Set user role Id. Can be: 1 - SysAdmin, 2 - Admin, 3 - User, 4 - Guest
$role->id = "3";
//Set user role name. Can be: SysAdmin, Admin, User, Guest
$role->name = "User";
//Create array of roles.
$roles = array($role);
//Set nick name as entered first name
$user->nickname = $firstName;
//Set first name as entered first name
$user->firstname = $firstName;
//Set last name as entered last name
$user->lastname = $lastName;
$user->roles = $roles;
//Set email as entered email
$user->primary_email = $email;
//Create new user.
$newUser = $mgmtApi->UpdateAccountUser($clientId, $email, $user);

if ($newUser->status = "Ok") {
//add new user to wp_groupdocs_users table
$rows_affected = $wpdb->insert( $table_name, array( 'email' => $email, 'guid' => $newUser->result->guid,)); }
else {
//Display "Failed to create user" message
echo 'Failed to create user.'; }
}
//Define user's guid:
if($user_guid == NULL){
$guid = $newUser->result->guid;}
else {
$guid = $user_guid->guid;}
//Create Annotation api object
$ant = new AntApi($apiClient);
$ant->setBasePath($basePath);
//Create array with entered email for SetAnnotationCollaborators method
$arrayEmail = array($email);
//Make request to Ant api for set new user as annotation collaborator
$addCollaborator = $ant->SetAnnotationCollaborators($clientId, $uuid2, "2.0", $arrayEmail);
if ($addCollaborator->status == "Ok") {
//Make request to Annotation api to receive all collaborators for entered file id
$getCollaborators = $ant->GetAnnotationCollaborators($clientId, $uuid2);
if ($getCollaborators->status == "Ok") {
$setReviewer = $ant->SetReviewerRights($guid, $uuid2, $getCollaborators->result->collaborators);
if ($setReviewer->status == "Ok") {
$iframe = $url. '?&uid=' . $guid;
$iframe = $signer->signUrl($iframe);}
else {/*throw new Exception($setReviewer->error_message);*/}
}
else { /*throw new Exception($getCollaborators->error_message);*/}
}
else { /*throw new Exception($addCollaborator->error_message);*/}
}
else {echo 'Please choose a file to upload';}
}
else
{
//display already shared document
$sql="SELECT uuid FROM wp_depositions where sessionId='$sessionId'";
mysql_connect(DB_HOST,DB_USER,DB_PASSWORD);
mysql_select_db(DB_NAME);
$result= mysql_query($sql);
if($row=mysql_fetch_array($result))
$uuid2=$row['uuid'];
if($uuid2!=""){
$signer = new GroupDocsRequestSigner($privateKey);
$apiClient = new APIClient($signer);
$mgmtApi = new MgmtApi($apiClient);
$url = "https://apps.groupdocs.com/document-annotation/embed/".$uuid2;
$signature = explode("=", $url);
$basePath = 'https://api.groupdocs.com/v2.0';
//If user does not already exist, create new user
$user_guid = $wpdb->get_row("SELECT guid FROM ".$table_name." WHERE email = '".$email."'");
if($user_guid == NULL){
//Create User info object
$user = new UserInfo();
//Create Role info object
$role = new RoleInfo();
//Set user role Id. Can be: 1 - SysAdmin, 2 - Admin, 3 - User, 4 - Guest
$role->id = "3";
//Set user role name. Can be: SysAdmin, Admin, User, Guest
$role->name = "User";
//Create array of roles.
$roles = array($role);
//Set nick name as entered first name
$user->nickname = $firstName;
//Set first name as entered first name
$user->firstname = $firstName;
//Set last name as entered last name
$user->lastname = $lastName;
$user->roles = $roles;
//Set email as entered email
$user->primary_email = $email;
//Creating of new user.
$newUser = $mgmtApi->UpdateAccountUser($clientId, $email, $user);
if ($newUser->status = "Ok") {
//add new user to wp_groupdocs_users table
$rows_affected = $wpdb->insert( $table_name, array( 'email' => $email, 'guid' => $newUser->result->guid,)); }
else {
//Display "Failed to create user" message
echo 'Failed to create user.'; }
}
//If NewUser created successfully or user already exists, create Annotation api object
//Define user's guid:
if($user_guid == NULL){
$guid = $newUser->result->guid;}
else {
$guid = $user_guid->guid;}
//Create Annotation api object
$ant = new AntApi($apiClient);
$ant->setBasePath($basePath);
//Create array with entered email for SetAnnotationCollaborators method
$arrayEmail = array($email);
//Make request to Ant api for set new user as annotation collaborator
$addCollaborator = $ant->SetAnnotationCollaborators($clientId, $uuid2, "2.0", $arrayEmail);
if ($addCollaborator->status == "Ok") {
//Make request to Annotation api to receive all collaborators for entered file id
$getCollaborators = $ant->GetAnnotationCollaborators($clientId, $uuid2);
if ($getCollaborators->status == "Ok") {
//Set reviewers rights for new user. $newUser->result->guid - GuId of created user, $uuid2 - entered file id,
//$getCollaborators->result->collaborators - array of collabotors in which new user will be added
$setReviewer = $ant->SetReviewerRights($guid, $uuid2, $getCollaborators->result->collaborators);
if ($setReviewer->status == "Ok") {
$iframe = $url. '?&uid=' . $guid;
$iframe = $signer->signUrl($iframe);
}
else {/*throw new Exception($setReviewer->error_message);*/}
}
else { /*throw new Exception($getCollaborators->error_message);*/}
}
else { /*throw new Exception($addCollaborator->error_message);*/}
}
}
}
?>



<?php

?>
<?php if($uuid2!=null) { ?>

<?php } ?>

Hi Todd,


Please send the instructions to this email - support@groupdocs.com. Also you can share your skype id and our developer support can contact you directly via Skype to resolve the issues/questions fast.


Many thanks,
Sergey

Sergey Zhuravel
GroupDocs Developer Support

Hi Todd1,

Thank you for your code sharing.

We investigated the code you provided and we can see some issues. Please check that in this part of code:

<?php
/**
* Bootstrap
*/
require("wp-config.php");
session_start();
require("src/APIClient.php");
ini_set('display_errors',1);
error_reporting(E_ALL);
global $wpdb;

$sessionId = $_GET['sessionId'];
$uuid2 = null;

//groupdocs API keys

$table_name = 'wp_groupdocs_users';

//get URL variables
$first_name = $_GET['first_name'];
$last_name = $_GET['last_name'];
$email = $_GET['email'];

//get user or invitee name from depositions or join page
if(!isset($first_name) || !isset($last_name) || !isset($email)){
?> <?
}

else {


//upload new document to GroupDocs & return iframe URL
if(isset($_POST['uploadfile'])&&($_POST['uploadfile'] == 'Display Document')){

//create iframe URL
$uploads_dir = '/var/www/uploads/';
$tmp_name = $_FILES["uploadedfile"]["tmp_name"];
if($tmp_name) {
$name = $_FILES["uploadedfile"]["name"];
$fs = FileStream::fromFile($tmp_name);
$signer = new GroupDocsRequestSigner($privateKey);
$apiClient = new APIClient($signer);
$mgmtApi = new MgmtApi($apiClient);
$api = new StorageApi($apiClient);
$result = $api->Upload($clientId, $name, 'uploaded', null, $fs);

There is used two undefined variables such as $clientId and $privateKey, you should declare them before using (the $clientId must be your clientId from GroupDocs account and $privateKey must be your private key - how to find them you can see here http://groupdocs.com/docs/display/documentation/How+to+Get+Your+GroupDocs+API+Keys). Also if you use: require("src/APIClient.php"); maybe you can try to do it for all GroupDocs api's you use like this: require("src/GroupDocsRequestSigner.php"); require("src/StorageApi.php"); require("src/MgmtApi.php"); and rest of them.

Also as we can see this is your first error: TB DynamicConfig failed to load in 4000 ms TB.min.js:32 This error means that TB.min.js (this is not a part of our SDK) is failed to load. Rest of errors may be result from this error. Also one recomendation: please use this URL for iframe
https://apps.groupdocs.com/document-annotation2/embed/
instead of
https://apps.groupdocs.com/document-annotation/embed/

Hope this will help you, if not please contact us and we will be glad to help you.

Also if it's possible for you, you can provide us a full copy of the script you are working on or a part of it and we can help to investigate and fix it for you.