Clint does not receive

4 views
Skip to first unread message

pilot

unread,
May 11, 2009, 12:06:20 PM5/11/09
to meteorserver
From my server I send to Meteor the following message:
{rows:[{id:1001,data:["100","A Time to Kill","John Grisham","12.99",
"1", "05/01/1998"]}]}

but nothing arrives to the client, even a syntax error.

From the firebug I can see the GET command which successfully returns
with no Response:
GET http://comet-domain/push/409897502705/xhrinteractive/ctrl.h?nc=1242057037689
200 OK 27ms

I replace my JASON string with a simple taken from the angst sample,
but with the same results.

Can I do something further?

Thanks

Jose Mico

unread,
May 11, 2009, 8:13:41 PM5/11/09
to meteorserver
That's because Meteor send the message string enclosed within quotes.
If your JSON message were:

{id:1001,data:["100","John"]}

Then Meteor add quotes and the message becomes:

"{id:1001,data:["100","John"]}"

...which isn't valid javascript due to added quotes.

There is two workarounds. One is to escape your message before sending
it, like:

{id:1001,data:[\"100\",\"John\"]}

Then Meteor add quotes and the message becomes:

"{id:1001,data:[\"100\",\"John\"]}"

...which is a valid javascript string (that you need to evaluate
yourself).

I'm also using Meteor to send JSON formatted data. I prefer to just
remove those quotes from the message template, inside meteord.conf.
Note that the ~text~ does not have enclosing quotes:

MessageTemplate Meteor.process(~id~,"~channel~",~text~);\r\n

Then the JSON is sent exactly as provided, and your callback function
will receive the evaluated JSON object instead of a plain string.

José

Lagos, Ioannis

unread,
May 12, 2009, 4:15:24 AM5/12/09
to meteor...@googlegroups.com
Thank you, and yes it is better to modify the template.

Well I did it, I restart meteord, and Client insists to have an empty response with no errors!
Before that I had syntax errors, which was normal because of quotes in Jason string.
But now, seems that somebody swallows the messages that never reach to the Client.

In order to further debug I simplify the string as use PuTTY giving:

GET /push/1/xhrinteractive/ctrl.h HTTP/1.1

And the result was:
<script>ch("ctrl", 0);</script>
<script>p(-1,"");</script>
...

No message arrives and I don't understand what is causing this situation.

Thanks

pilot

unread,
May 12, 2009, 5:28:16 AM5/12/09
to meteorserver
To a further investigation, if I use a PuTTY to add a message, then my
Client receives the messages as:

<script>ch("ctrl", 0);</script>
Meteor.process(0,"ctrl",{rows:[{id:1001,data:"100","A Time to
Kill","John Grisham","12.99","1","05/01
/1998"]}]});

For some reason the ADDMESSAGE from the php script I use, never reach
the Meteor's 4671 port, or something else happened.
Into the php script I copied the code from a sample of yours I found
in the Meteor's site and it is as:

if (!is_resource($op) or feof($op) or ($haswritten and !$buf)) {
echo "Reconnecting to Meteor\n";
if (!($op = fsockopen("127.0.0.1", 4671, $errno, $errstr, 5))) {
echo "Meteor not responding\n";
sleep(5);
continue;
}
socket_set_blocking($op,false);
}


$haswritten = false;
$buf = "";

$msg="{rows:[{id:1001,data:"
.'\"100\",\"A Time to Kill\",\"John Grisham\",\"12.99\",\"1\",
\"05/01/1998\"]}]}';

$out = "ADDMESSAGE ".$ch_ctrl." ".$msg;

$haswritten=true;
fwrite($op, $out);


Thanks in advance,
pilot

Jose Mico

unread,
May 12, 2009, 9:29:13 AM5/12/09
to meteorserver
That code is not mine, I'm using a custom client written in Perl to
inject messages (that by the way I can share if someone is
interested). So I really have no idea about this PHP client...

The only thing that I can see in that code is the missing "\r\n" at
the end of the $out string, that actually will send a bad formatted
command to Meteor.

José

Lagos, Ioannis

unread,
May 12, 2009, 9:54:32 AM5/12/09
to meteor...@googlegroups.com
Yew, one cause of that problem was the missing "\r\n".

Thanks

-----Original Message-----
From: meteor...@googlegroups.com [mailto:meteor...@googlegroups.com] On Behalf Of Jose Mico
Sent: Tuesday, May 12, 2009 4:29 PM
To: meteorserver
Subject: Re: Clint does not receive


Chris James

unread,
Jul 8, 2009, 2:03:18 PM7/8/09
to meteorserver
I also had the same issue. I went ahead and changed the Config.pm to
this on line 88 :
MessageTemplate => "<script>p(~id~,'~channel~','~text~');</script>\r
\n"

notice how i changed the quotes from single to double on the outside
and then double to single on the inside of script tags. works like a
charm... and is valid JS... just not wonderful.

saladyears

unread,
Jul 9, 2009, 12:11:28 PM7/9/09
to meteorserver

Couldn't you use escape() and unescape() on your JSON to send it
across your channel?
Reply all
Reply to author
Forward
0 new messages