now.distributeMessage is not a function

273 views
Skip to first unread message

Don

unread,
May 17, 2011, 10:54:23 PM5/17/11
to nowjs
Greetings, following examples and getting error in Firebug console

now.distributeMessage is not a function

now.distributeMessage($("#text-input").val());

Getting this when I try to send a message. Thanks for any help.

Don

unread,
May 17, 2011, 10:58:52 PM5/17/11
to nowjs
I also want to note this log when starting the server.

17 May 22:51:56 - socket.io ready - accepting connections
{ stack: [Getter/Setter],
arguments: [ 'limits', undefined ],
type: 'non_object_property_load',
message: [Getter/Setter] }
TypeError: Cannot read property 'limits' of undefined
at Object.initialize (/usr/lib/node/.npm/now/0.6.0/package/lib/
nowServerLib.js:297:48)
at Object.<anonymous> (/Users/[REMOVED]/Sites/local_test/
server_now.js:12:22)
at Module._compile (module.js:404:26)
at Object..js (module.js:410:10)
at Module.load (module.js:336:31)
at Function._load (module.js:297:12)
at Array.<anonymous> (module.js:423:10)
at EventEmitter._tickCallback (node.js:126:26)
could not connect to lb
{ stack: [Getter/Setter],
arguments: undefined,
type: undefined,
message: 'Redis connection to 127.0.0.1:6379 failed - ECONNREFUSED,
Connection refused' }
Error: Redis connection to 127.0.0.1:6379 failed - ECONNREFUSED,
Connection refused
at Socket.<anonymous> (/usr/lib/node/.npm/now/0.6.0/package/
node_modules/redis/index.js:120:28)
at Socket.emit (events.js:64:17)
at Array.<anonymous> (net.js:828:27)
at EventEmitter._tickCallback (node.js:126:26)

Darshan Shankar

unread,
May 18, 2011, 3:27:53 PM5/18/11
to no...@googlegroups.com
Hey Don,

There was a bug in the nowjs on npm that has been fixed. Please uninstall nowjs (npm uninstall now) and reinstall nowjs (npm install now). 

Darshan
--
Darshan Shankar

Don

unread,
May 18, 2011, 5:06:45 PM5/18/11
to nowjs
I uninstalled nowjs and re-installed. It seems to install the same
version. I could be wrong. I'm getting the same errors.

iMac:~ [REMOVED]$ npm uninstall now
npm info it worked if it ends with ok
npm info using n...@0.3.18
npm info using no...@v0.4.7
npm info preuninstall n...@0.6.0
npm info uninstall n...@0.6.0
npm info predeactivate n...@0.6.0
npm info deactivate n...@0.6.0
npm info postdeactivate n...@0.6.0
npm info postuninstall n...@0.6.0
npm info uninstall n...@0.6.0 complete
npm ok
iMac:~ [REMOVED]$ npm install now
npm info it worked if it ends with ok
npm info using n...@0.3.18
npm info using no...@v0.4.7
npm info preinstall n...@0.6.0
npm info install n...@0.6.0
npm info postinstall n...@0.6.0
npm info preactivate n...@0.6.0
npm info activate n...@0.6.0
npm info postactivate n...@0.6.0
npm info build Success: n...@0.6.0
npm ok

Don

unread,
May 18, 2011, 5:30:45 PM5/18/11
to nowjs
This is the errors I'm getting. Thanks.

18 May 17:29:06 - socket.io ready - accepting connections
{ stack: [Getter/Setter],
arguments: [ 'limits', undefined ],
type: 'non_object_property_load',
message: [Getter/Setter] }
TypeError: Cannot read property 'limits' of undefined
at Object.initialize (/usr/lib/node/.npm/now/0.6.0/package/lib/
nowServerLib.js:297:48)
at Object.<anonymous> (/Users/[REMOVED]/Sites/local_test/
server_now.js:11:31)
at Module._compile (module.js:404:26)
at Object..js (module.js:410:10)
at Module.load (module.js:336:31)
at Function._load (module.js:297:12)
at Array.<anonymous> (module.js:423:10)
at EventEmitter._tickCallback (node.js:126:26)
could not connect to lb
{ stack: [Getter/Setter],
arguments: undefined,
type: undefined,
message: 'Redis connection to 127.0.0.1:6379 failed - ECONNREFUSED,
Connection refused' }
Error: Redis connection to 127.0.0.1:6379 failed - ECONNREFUSED,
Connection refused
at Socket.<anonymous> (/usr/lib/node/.npm/now/0.6.0/package/
node_modules/redis/index.js:120:28)
at Socket.emit (events.js:64:17)
at Array.<anonymous> (net.js:828:27)
at EventEmitter._tickCallback (node.js:126:26)


On May 18, 5:06 pm, Don <don.newelem...@gmail.com> wrote:
> I uninstalled nowjs and re-installed. It seems to install the same
> version. I could be wrong. I'm getting the same errors.
>
> iMac:~ [REMOVED]$ npm uninstall now
> npm info it worked if it ends with ok
> npm info using n...@0.3.18
> npm info using n...@v0.4.7
> npm info preuninstall n...@0.6.0
> npm info uninstall n...@0.6.0
> npm info predeactivate n...@0.6.0
> npm info deactivate n...@0.6.0
> npm info postdeactivate n...@0.6.0
> npm info postuninstall n...@0.6.0
> npm info uninstall n...@0.6.0 complete
> npm ok
> iMac:~ [REMOVED]$ npm install now
> npm info it worked if it ends with ok
> npm info using n...@0.3.18
> npm info using n...@v0.4.7

Don

unread,
May 18, 2011, 5:35:24 PM5/18/11
to nowjs
All I'm doing is starting the server, node server_now.js, and I get
the errors in terminal

This is the server_now.js

var fs = require('fs');
var server = require('http').createServer(function(req, response){
fs.readFile('client_nowjs.html', function(err, data){
response.writeHead(200, {'Content-Type':'text/html'});
response.write(data);
response.end();
});
});
server.listen(8181);

var everyone = require('now').initialize(server);

everyone.connected(function(){
console.log("Joined: " + this.now.name);
});

everyone.disconnected(function(){
console.log("Left: " + this.now.name);
});

everyone.now.distributeMessage = function(message){
everyone.now.receiveMessage(this.now.name, message);
};

Vladimir Dronnikov

unread,
May 18, 2011, 5:47:40 PM5/18/11
to no...@googlegroups.com
>  message: 'Redis connection to 127.0.0.1:6379 failed - ECONNREFUSED,

Seems like the team started on load balancer.
You should install https://github.com/antirez/redis and
https://github.com/mranney/node_redis.
The latter is available as `npm install redis`

Best regards,
--Vladimir

Darshan Shankar

unread,
May 18, 2011, 5:50:33 PM5/18/11
to no...@googlegroups.com
Actually don't do that. The load balancer isn't meant to be in integrated into nowjs 0.6.0, we made a mistake.

Give us a few minutes, we will fix nowjs and publish to npm soon. Sorry for the bugs.
--
Darshan Shankar

Darshan Shankar

unread,
May 18, 2011, 5:58:20 PM5/18/11
to no...@googlegroups.com
This has been fixed. Please reinstall NowJS.

Do "npm uninstall now" and "npm install now" again
--
Darshan Shankar

Jay Are Galinada

unread,
Jul 24, 2012, 11:57:55 PM7/24/12
to no...@googlegroups.com
I still get the error
TypeError: now.distributeMessage is not a function

Nate Morse

unread,
Jul 25, 2012, 9:14:23 AM7/25/12
to no...@googlegroups.com
I am missing your thread of conversation on this,
Would you share the code/context that is causing this error? Or a simple (server and client code) example that exhibits this TypeError. 
--Thanks

Jay Are Galinada

unread,
Jul 26, 2012, 4:49:31 AM7/26/12
to no...@googlegroups.com


Noong Miyerkules, Hulyo 25 2012 21:14:23 UTC+8, si Nate ay sumulat:
I am missing your thread of conversation on this,
Would you share the code/context that is causing this error? Or a simple (server and client code) example that exhibits this TypeError. 
--Thanks


Visit http://jayare.swakfm.com:8000
I run the nowjs in port 8000 and when I want to add text/message I got this kind of error in the console log
I used the example in the video.

Nate Morse

unread,
Jul 26, 2012, 9:59:57 AM7/26/12
to no...@googlegroups.com
Your demo actually works for me, so unless you have fixed something, it might be an intermittent timing problem. 
You might try waiting for the "now.ready" event, before you do start up all your now code.

// see now.ready( function () { // added to wait for the now object to be fully initialized.


$(function(){
    now.ready( function () { // added to wait for the now object to be fully initialized.
        now.name = prompt("My name is?", "");
        console.log(now);
        now.receiveMsg = function(name, msg){
            $("<div></div>").text(name +" : "+ msg).appendTo("#msg"); 
        };
        $("#send").click(function(){
            var text = $("#text").val();
            now.distributeMsg(text);
            $("#text").val("");
        });
    });
})

Jay Are Galinada

unread,
Jul 27, 2012, 5:50:40 AM7/27/12
to no...@googlegroups.com
It seems like it doesn't work that way, I've tried everything what I can do, but still, it doesn't work.
I also used the code above but the prompt function doesn't run.

Noong Huwebes, Hulyo 26 2012 21:59:57 UTC+8, si Nate ay sumulat:

Nate Morse

unread,
Jul 27, 2012, 10:17:54 AM7/27/12
to no...@googlegroups.com
--strange-- that it does not work for you. Using FF and Chrome it works for me, with no errors.
Are you seeing any errors?

Jay Are Galinada

unread,
Jul 27, 2012, 10:41:34 PM7/27/12
to no...@googlegroups.com
Yeah, no errors and not running, and the prompt function doesn't execute in the first load as expected. However, the polling is executed every time.
I'm using Firefox v14.0.1 and Google Chrome v20.0.1132.57 m
This is my nodejs server configuration

var fs = require("fs");
var http = require("http");
var nowjs = require("now");
server = http.createServer(function(req, res){
    fs.readFile("index.html", function(err, data){
        res.writeHead(200, {"Content-Type": "text/html"});
        res.write(data);
        res.end();
    });
});
server.listen(8000);

// nowjs here

var everyone = nowjs.initialize(server);
console.log(everyone);
console.log(server.listen());
everyone.now.distributeMsg = function(msg){
    everyone.now.receiveMsg(this.now.name, msg);
};

Noong Biyernes, Hulyo 27 2012 22:17:54 UTC+8, si Nate ay sumulat:
Reply all
Reply to author
Forward
0 new messages