liveUpdate error


#1

Referring to the documentation at http://docs.dhtmlx.com/scheduler/live_update.html
I notice there hasn’t been much activity there in a while, so I’m posting my comment and question here as well. Hope I’m on the right forum for this question.

Comment and a question:

  1. on a Debian (Linux Mint) I had to change the command to nodejs nodejs/server.js to start the server.
    (from node nodejs/server.js)
  2. Is the file update.php literally the file located in the codebase/connector folder in the scheduler download? If it is, I am getting this error:
    Fatal error: Class ‘DataItem’ not found in /var/www/html/worksite/testCal/codebase/connector/update.php on line 12
    Help, anyone?

Live updates addEvent error
#2

update.php is not literally located in the codebase/connector.
This file will recieve data from your client side and should save it.
See article:
docs.dhtmlx.com/scheduler/how_to … sidescript


#3

Thanks, Sten. The reason I asked was because in the same article in one instance that file is referred to as “scheduler.php”, then further down the page as “update.php”, and I’ve seen this sort of discrepancy more than once. Well, some other reason then why I’m not getting the live update working, at least not seeing the results I am expecting.


#4

Ok, I do have it working now. Problem was with “localhost” reference to sync.js.

However, there is an error that occurs on creating a new event, similar to the issue at http://forum.dhtmlx.com/viewtopic.php?f=6&t=32650. However, in that instance the culprit seemed to be live_update.js.

trace:
Uncaught TypeError: Cannot read property ‘valueOf’ of undefinedscheduler.addEvent @ dhtmlxscheduler.js:3702
scheduler.add @ live_updates.js:204
(anonymous function) @ live_updates.js:33
dataProcessor.ignore @ dhtmlxscheduler.js:1347
(anonymous function) @ live_updates.js:32(anonymous function) @ sync.js:1
Faye.extend.each @ sync.js:1
Faye.Publisher.publishEvent @ sync.js:1
(anonymous function) @ sync.js:1
Faye.extend.each @ sync.js:1
Faye.extend.Set.Faye.Class.distributeMessage @ sync.js:1
Faye.Client.Faye.Class._A @ sync.js:1
(anonymous function) @ sync.js:1
Faye.Extensible.pipeThroughExtensions @ sync.js:1
Faye.Client.Faye.Class.receiveMessage @ sync.js:1
Faye.extend.each @ sync.js:1
Faye.Transport.Faye.extend.Faye.Class.receive @ sync.js:
1_b.onmessage @ sync.js:1

If someone wants to view the entire configuration online, I can set it up.
Thanks


#5

I have a safe site set up to view the calendar and code.
http://asbs.ddns.net/worksite/testCal/calendar4.php

Also, below is the code of my connector, if it’s relevant.

[code]error_reporting(E_ALL);
require_once(’./codebase/connector/scheduler_connector.php’);
include “…/phpFunctions/nothing.php”;

mysqli_select_db($con, $dbname);

$list = new OptionsConnector($con);
$sql = “SELECT VID as value, name as label FROM craftsmen WHERE vStatus = ‘Active’”;
$list->render_sql($sql, “VID”, “VID(value), name(label)”);

$res = new SchedulerConnector($con);
$res->set_options(“craftsmen”, $list);
$res->render_table(“events”);

mysqli_close($con);
unset($con);
unset($sql);
unset($list);
unset($res);[/code]

Thanks


#6

Ok, so now I’ve broken it.

I tried the other live_updates.js file in the forum mentioned above http://forum.dhtmlx.com/viewtopic.php?f=6&t=32650, but that has now screwed everything up and so far, all my attempts to clean out cache, reinstall the nodejs folder, restart the apache server, restart the nodejs server, etc, has had no effect.

Arrrrrhhhhhhh!


#7

For the sake of generations to come:
I fixed it. I noticed that the safe version mentioned above wasn’t throwing the same error. The only difference is that I had hard-coded some php vars (user, order number, etc) that relate to the database. So, I copied and renamed the file – set the variables back to the php session vars – and eureka! It works again!

Ok, but still problem with Uncaught TypeError: Cannot read property ‘valueOf’ of undefinedscheduler.addEvent @ dhtmlxscheduler.js:3702.
?


#8

Hello? Anybody home?


#9

Hi,

Ok, but still problem with Uncaught TypeError: Cannot read property ‘valueOf’ of undefinedscheduler.addEvent @ dhtmlxscheduler.js:3702.

Seems like it happens on this line
github.com/DHTMLX/scheduler/blo … r.js#L3702
So it must be caused by adding a new event with an undefined start or end_date. Can you check the call trace of the error to see from where the method is called?


#10

Firebug says:
TypeError: n.start_date is undefined dhtmlxscheduler.js (line 186, col 315)
and quits there.

Chrome has the following:
scheduler.addEvent @ dhtmlxscheduler.js:3702
scheduler.add @ live_updates.js:204
(anonymous function) @ live_updates.js:33
dataProcessor.ignore @ dhtmlxscheduler.js:1347
(anonymous function) @ live_updates.js:32
(anonymous function) @ sync.js:1
Faye.extend.each @ sync.js:1
Faye.Publisher.publishEvent @ sync.js:1
(anonymous function) @ sync.js:1
Faye.extend.each @ sync.js:1
Faye.extend.Set.Faye.Class.distributeMessage @ sync.js:1
Faye.Client.Faye.Class._A @ sync.js:1
(anonymous function) @ sync.js:1
Faye.Extensible.pipeThroughExtensions @ sync.js:1
Faye.Client.Faye.Class.receiveMessage @ sync.js:1
Faye.extend.each @ sync.js:1
Faye.Transport.Faye.extend.Faye.Class.receive @ sync.js:1
_b.onmessage @ sync.js:1

Is there more I can do?


#11

I added another extension to FF and got a little more info:

TypeError: n.start_date is undefined
scheduler.addEvent()
dhtmlxscheduler.js:186
scheduler.add()
live_updates.js:203
dataProcessor.prototype.live_updates/lu.subscription</<()
live_updates.js:32
dataProcessor.prototype.ignore()
dhtmlxscheduler.js:65
dataProcessor.prototype.live_updates/lu.subscription<()
live_updates.js:31
Faye.Publisher.publishEvent/<()
sync.js:1
.each()
sync.js:1
Faye.Publisher.publishEvent()
sync.js:1
.Set<.distributeMessage/<()
sync.js:1
.each()
sync.js:1
.Set<.distributeMessage()
sync.js:1
Faye.Client<._A()
sync.js:1
Faye.Client<.receiveMessage/<()
sync.js:1
Faye.Extensible.pipeThroughExtensions()
sync.js:1
Faye.Client<.receiveMessage()
sync.js:1
.each()
sync.js:1
Faye.Transport<.receive()
sync.js:1
Faye.Transport.WebSocket<.connect/this._b.onmessage()
sync.js:1
dhtmlxscheduler.js:186:315


#12

Also, found the following:
SyntaxError: Unexpected token < at Object.parse (native) at Object.dataProcessor.afterUpdate (…dhtmlxscheduler.js:17:251)

and this in scope/locals
responseText:"<?xml version='1.0' ?>"

Which I thought was odd since this is a new insertion. I would have expected tid to have a value and sid no value.


#13

Ok, I know what the problem is.
In the line (around line 3702, beautified)

scheduler.addEvent = function(start_date, end_date, text, id, extra_data) {

“start_date” is a JSON object that actually contains all the data (including extra_data), and as far as I can tell, the other four arguments are superfluous. I tested it first with console.log(start_date) and got back [object Object]. Then, I tested it with JSON.stringify() and got back a valid string of stuff. Of course, that means that the following definitions such as “ev.start_date = start_date;” are all screwed up.

In its present form, the expression “start_date.start_date” returns a valid start_date.

I would change the argument “start_date” to “data” or something.

So, I’m trying to fix but it might be a chore for me not knowing all the ins and outs. When might I expect an update?


#14

I should mention too, or reiterate, that the error only occurs in context with live update. With live update turned off, there is no error. Maybe, the root of the problem is somewhere else?


#15

Ok, after about a dozen or so typeof checks in dhtmlxscheduler.js and dhtmlxscheduler_limit.js I have it fixed. Scheduler and live update are alive and well, and living amicably together.

Where should I send the bill?


#16

Hi ,

I had similar issue with Gantt component and I fixed the date format on back-end. After that when i re-initialise the Gantt with proper date in successive service calls, the gantt is failing to initialise, as it throws same error as below.

“cannot read property valueof of undefined”

if i hard-refresh the page on browser and try accessing Gantt, then it loads fine.

does anyone know how to fix the problem, without refresh ?


#17

Was exactly the same problem for me in Scheduler. After a refresh, everything was there, but there was this error before


#18

I’m happy that you did it. Could you share the solution for that?


#19

That was so long ago I don’t remember the specifics, except that typeof checks worked for me in about a dozen instances in the two files I mentioned above. I could share those files, but that was four years ago, and I doubt if they are still valid. Also, while the files state that they are under GPL license, I would prefer to know that sharing them would not violate a trust with DHX. If you can check on that and let me know what DHX has to say, I’ll make those files where you can easily copy them online. Ed


#20

Hi @jazcam
looks like I’ve disappeared from this thread right after asking you for the details back then, sorry about that.:neutral_face:

As for sharing modified GPL files - we have absolutely no problem with that.

@Contente

Regarding the issues with the live update module, since it was never included in the main package there hasn’t been any activity for a really long time.
But we do have an updated dev version which should work with the latest dhtmlxscheduler and Faye, which I can share

Download links (I’m also attaching those to the post)
Live updates: https://files.dhtmlx.com/30d/868033035d111d2259ad83d72be7468e/live_updates.zip
Demo: https://files.dhtmlx.com/30d/8894760b70ca39e07b620961562f4340/scheduler-live-updates-app.zip

The demo package consists of two apps:

  1. One is a web app with dhtmlxScheduler, which is taken from here https://github.com/DHTMLX/scheduler-howto-node

  2. And the other is live update service, it’s implemented as a separate app here.

Faye app (scheduler-live-updates-app.zip/live-update/server.js) is mostly the same as in the live-update sample you’ve downloaded before. You can find the code file in scheduler-live-updates-app.zip/live-update/server.js

As for the scheduler app (scheduler-live-updates-app.zip/scheduler), I’ve made some changes to the scheduler app in order to connect live updates to it.

I didn’t want to hardcode Faye urls to html pages (http://localhost:8008/), so I’ve added a proxy route that will redirect routes from the local url to live updates app (/liveUpdates->http://localhost:8008), you can find it in scheduler/hook_live_updates.js.
It means that all requests from the front-end that starts with /liveUpdates are redirected to live-updates app.

On the front-end:

Added live_update.js and the faye client:

<script src="https://cdn.dhtmlx.com/scheduler/edge/dhtmlxscheduler.js" charset="utf-8"></script>
<script src="./lib/dhtmlxscheduler/live_updates.js"></script>
<script src="/liveUpdates/client.js"></script>

And connected the live update module to the data processor.

// connect backend to scheduler
var dp = new dataProcessor("/events");
dp.live_updates("/liveUpdates");

How to run:

Open the terminal and run the Faye app:

cd live-update
npm install
npm run start

Open another terminal window and run the scheduler app:

cd scheduler
npm install
npm run start

open http://localhost:3000/

Everything seems working correctly on my end, both Basic and Recurring events examples should work.

The updated live_updates.js seems to work ok with the latest scheduler.
No changes in dhtmlxscheduler library seem to be required, but there may be some issues we’re not aware of.

Note, that scheduler app requires MySQL database, which you need to import from scheduler-live-updates-app.zip\scheduler\mysql_dump.sql and update database connection settings in scheduler\server.js.

Also please note that the live update module is attached to the dataprocessor, and it won’t broadcast changes if the dataProcessor gets the error action status from the server.
In this package, I’ve commented out error responses on the server (https://github.com/DHTMLX/scheduler-howto-node/blob/master/router.js#L9-L10) so it always reports success even if it’s actually not. This is so you can test live updates without setting up the database. If you’re going to reuse these apps, you may want to rollback changes in router.js (scheduler-live-updates-app.zip/scheduler/router.js)

live_updates.zip (1.6 KB)
scheduler-live-updates-app.zip (10.1 KB)


Live updates addEvent error