Re: [nox-dev] Receiving JSON messages

2012-01-29 Thread Giorgio Mazza

A little update and a further question :)

With destiny's messenger my component works, even adding jsonmessenger 
as a dependency. Also Jsonmsg_events are raised and handled without 
errors by my callback and I solved the dummy timer problem with the 
client disconnection.


Now, I have a strange behaviour with my callback that seems to handle 
only messages that have the default syntax described in jsonmessenger.hh 
( just above the definition of the jsonmessenger class).
If I send a 'connect' or a 'disconnect' message it is handled by my 
callback, while, if I send a different message (that's what I want to 
do), jsonmessenger posts a JSONMsg_event, that it is simply ignored by 
my callback.


That 's a snippet of my install function:

from nox.coreapps.messenger.pyjsonmsgevent import JSONMsg_event
JSONMsg_event.register_event_converter(self.ctxt)
self.register_handler(JSONMsg_event.static_get_name(), 
self.json_message_callback)



That's my (temporary) callback:

def json_message_callback(self, e):
import json
global cache_server_table
message = json.loads(e.jsonstring)
cache_server_table.update(message)
print message
print cache_server_table
e.reply(json.dumps({"MSG":"Welcome! I am the Controller"}))
if cache_server_table.has_key("MSG"):
print cache_server_table["MSG"]
if cache_server_table["MSG"] == "Connection setup":
cache_server_MAC = cache_server_table["MAC"]
print cache_server_MAC
return CONTINUE


And that's what I get as output:

00046|nox|INFO:nox bootstrap complete
00047|messenger_core|DBG:Starting connection with idleInterval 0
00048|jsonmessenger|DBG:JSON message of length 18 (connect)
00049|jsonmessenger|DBG:JSON message of length 18
00050|jsonmessenger|DBG:JSON: {"type":"connect"}
{u'type': u'connect'} <--- the two print instruction
{u'type': u'connect'} <--- in the callback
00051|messenger_core|DBG:Sent string of length 39 socket 0x8e536c0
00052|messenger_core|DBG:TCP socket connection accepted
00053|messenger_core|DBG:Copy 74 bytes to message
00054|messenger_core|DBG:Received packet of length 74
00055|jsonmessenger|DBG:JSON message of length 74
00056|jsonmessenger|DBG:Message posted as JSONMsg_event 
<- after that I would expect the 
output of my callback (the two print instruction)
00057|jsonmessenger|DBG:JSON: 
{"MAC":"08:00:27:cc:77:1c","IP":"10.0.10.2","MSG":"Connection setup"}

00058|messenger_core|DBG:Copy 22 bytes to message
00059|messenger_core|DBG:Received packet of length 22
00060|jsonmessenger|DBG:JSON message of length 22
00061|jsonmessenger|DBG:Message posted as JSONMsg_event
00062|jsonmessenger|DBG:JSON: {"type":"disconnect"}
00063|jsonmessenger|DBG:Clear connection state for 0x8e536c0
{u'type': u'disconnect'}
{u'type': u'disconnect'}


So, the question is: Why my callback does not handle events posted by 
jsonmessenger? How can I fix that? Is there any particular syntax I have 
to follow so that it is a json-related error?


Thanks in advance.

Regards,
Giorgio


On 27/01/2012 16:42, kk yap wrote:

Hi Giorgio,

Your client is disconnecting before the reply is sent.  If you look at
nox-console.py, it should be a good example to follow.

Regards
KK

On 27 January 2012 05:12, Kyriakos Zarifis  wrote:

A JSONMsg_event is just another NOX event and us such it will either passed
on to all components down the event handler chain or stopped by one of them.
Your handler needs to return a valid NOX event disposition (
http://noxrepo.org/noxwiki/index.php/Disposition  )
So in your case you just need to add a "return STOP" and the error will
disappear.


As for the other comment, I'm not sure how messenger_core cleans the
connections state/closes socket. It might very well be a timing issue, maybe
the connection state hasn't been cleaned when the event is processed. I
don't know if the log messages represent the reality 100%. In any case the
last message is either never really sent or it's sent to the void. Either
way I'd just ignore it, I doubt it will affect anything


On Fri, Jan 27, 2012 at 3:02 AM, Giorgio Mazza
wrote:

I tried this way:  I replaced zaku's default messenger folder with
destiny's messenger one (nox/src/nox/coreapps/messenger), that I had
previously downloaded and installed.
Then I recompiled zaku and the import error disappeared, so that when I
run
./nox_core -v -i ptcp:6633 jsonmessenger=tcpport=3334 my_component
I do not get errors anymore and components are installed successfully.
However, when I try to send a json message from my external application I
get a strange behaviour. I don't understand very well what is happening and
why I get this error, so I do not know if it is my fault in doing something
or if I need to hack something because the simple replacement of messenger
folder is not enough.

My callback is fairly simple for the moment and

Re: [nox-dev] Receiving JSON messages

2012-01-29 Thread kk yap
Hi,

Reading the documentation might help.
http://noxrepo.org/~yapkke/doc/classvigil_1_1jsonmessenger.html#_details

Try have a type field.

Regards
KK

On 29 January 2012 07:34, Giorgio Mazza  wrote:
> A little update and a further question :)
>
> With destiny's messenger my component works, even adding jsonmessenger as a
> dependency. Also Jsonmsg_events are raised and handled without errors by my
> callback and I solved the dummy timer problem with the client disconnection.
>
> Now, I have a strange behaviour with my callback that seems to handle only
> messages that have the default syntax described in jsonmessenger.hh ( just
> above the definition of the jsonmessenger class).
> If I send a 'connect' or a 'disconnect' message it is handled by my
> callback, while, if I send a different message (that's what I want to do),
> jsonmessenger posts a JSONMsg_event, that it is simply ignored by my
> callback.
>
> That 's a snippet of my install function:
>
> from nox.coreapps.messenger.pyjsonmsgevent import JSONMsg_event
> JSONMsg_event.register_event_converter(self.ctxt)
> self.register_handler(JSONMsg_event.static_get_name(),
> self.json_message_callback)
>
>
> That's my (temporary) callback:
>
> def json_message_callback(self, e):
>         import json
>         global cache_server_table
>         message = json.loads(e.jsonstring)
>         cache_server_table.update(message)
>         print message
>         print cache_server_table
>         e.reply(json.dumps({"MSG":"Welcome! I am the Controller"}))
>         if cache_server_table.has_key("MSG"):
>             print cache_server_table["MSG"]
>             if cache_server_table["MSG"] == "Connection setup":
>                 cache_server_MAC = cache_server_table["MAC"]
>                 print cache_server_MAC
>         return CONTINUE
>
>
> And that's what I get as output:
>
> 00046|nox|INFO:nox bootstrap complete
> 00047|messenger_core|DBG:Starting connection with idleInterval 0
> 00048|jsonmessenger|DBG:JSON message of length 18 (connect)
> 00049|jsonmessenger|DBG:JSON message of length 18
> 00050|jsonmessenger|DBG:JSON: {"type":"connect"}
> {u'type': u'connect'}
> <--- the two print instruction
> {u'type': u'connect'}
> <--- in the callback
> 00051|messenger_core|DBG:Sent string of length 39 socket 0x8e536c0
> 00052|messenger_core|DBG:TCP socket connection accepted
> 00053|messenger_core|DBG:Copy 74 bytes to message
> 00054|messenger_core|DBG:Received packet of length 74
> 00055|jsonmessenger|DBG:JSON message of length 74
> 00056|jsonmessenger|DBG:Message posted as JSONMsg_event
> <- after that I would expect the
> output of my callback (the two print instruction)
> 00057|jsonmessenger|DBG:JSON:
> {"MAC":"08:00:27:cc:77:1c","IP":"10.0.10.2","MSG":"Connection setup"}
> 00058|messenger_core|DBG:Copy 22 bytes to message
> 00059|messenger_core|DBG:Received packet of length 22
> 00060|jsonmessenger|DBG:JSON message of length 22
> 00061|jsonmessenger|DBG:Message posted as JSONMsg_event
>
> 00062|jsonmessenger|DBG:JSON: {"type":"disconnect"}
> 00063|jsonmessenger|DBG:Clear connection state for 0x8e536c0
> {u'type': u'disconnect'}
> {u'type': u'disconnect'}
>
>
> So, the question is: Why my callback does not handle events posted by
> jsonmessenger? How can I fix that? Is there any particular syntax I have to
> follow so that it is a json-related error?
>
> Thanks in advance.
>
> Regards,
> Giorgio
>
>
>
> On 27/01/2012 16:42, kk yap wrote:
>
> Hi Giorgio,
>
> Your client is disconnecting before the reply is sent.  If you look at
> nox-console.py, it should be a good example to follow.
>
> Regards
> KK
>
> On 27 January 2012 05:12, Kyriakos Zarifis  wrote:
>
> A JSONMsg_event is just another NOX event and us such it will either passed
> on to all components down the event handler chain or stopped by one of them.
> Your handler needs to return a valid NOX event disposition (
> http://noxrepo.org/noxwiki/index.php/Disposition  )
> So in your case you just need to add a "return STOP" and the error will
> disappear.
>
>
> As for the other comment, I'm not sure how messenger_core cleans the
> connections state/closes socket. It might very well be a timing issue, maybe
> the connection state hasn't been cleaned when the event is processed. I
> don't know if the log messages represent the reality 100%. In any case the
> last message is either never really sent or it's sent to the void. Either
> way I'd just ignore it, I doubt it will affect anything
>
>
> On Fri, Jan 27, 2012 at 3:02 AM, Giorgio Mazza 
> wrote:
>
> I tried this way:  I replaced zaku's default messenger folder with
> destiny's messenger one (nox/src/nox/coreapps/messenger), that I had
> previously downloaded and installed.
> Then I recompiled zaku and the import error disappeared, so that when I
> run
> ./nox_core -v -i ptcp:6633 jsonmessenger=tcpport=3334 my_component
> I do not get errors anymore and components a

Re: [nox-dev] Receiving JSON messages

2012-01-29 Thread Giorgio Mazza

It was the type field, thanks!

On 29/01/2012 16:45, kk yap wrote:

Hi,

Reading the documentation might help.
http://noxrepo.org/~yapkke/doc/classvigil_1_1jsonmessenger.html#_details

Try have a type field.

Regards
KK

On 29 January 2012 07:34, Giorgio Mazza  wrote:

A little update and a further question :)

With destiny's messenger my component works, even adding jsonmessenger as a
dependency. Also Jsonmsg_events are raised and handled without errors by my
callback and I solved the dummy timer problem with the client disconnection.

Now, I have a strange behaviour with my callback that seems to handle only
messages that have the default syntax described in jsonmessenger.hh ( just
above the definition of the jsonmessenger class).
If I send a 'connect' or a 'disconnect' message it is handled by my
callback, while, if I send a different message (that's what I want to do),
jsonmessenger posts a JSONMsg_event, that it is simply ignored by my
callback.

That 's a snippet of my install function:

from nox.coreapps.messenger.pyjsonmsgevent import JSONMsg_event
JSONMsg_event.register_event_converter(self.ctxt)
self.register_handler(JSONMsg_event.static_get_name(),
self.json_message_callback)


That's my (temporary) callback:

def json_message_callback(self, e):
 import json
 global cache_server_table
 message = json.loads(e.jsonstring)
 cache_server_table.update(message)
 print message
 print cache_server_table
 e.reply(json.dumps({"MSG":"Welcome! I am the Controller"}))
 if cache_server_table.has_key("MSG"):
 print cache_server_table["MSG"]
 if cache_server_table["MSG"] == "Connection setup":
 cache_server_MAC = cache_server_table["MAC"]
 print cache_server_MAC
 return CONTINUE


And that's what I get as output:

00046|nox|INFO:nox bootstrap complete
00047|messenger_core|DBG:Starting connection with idleInterval 0
00048|jsonmessenger|DBG:JSON message of length 18 (connect)
00049|jsonmessenger|DBG:JSON message of length 18
00050|jsonmessenger|DBG:JSON: {"type":"connect"}
{u'type': u'connect'}
<--- the two print instruction
{u'type': u'connect'}
<--- in the callback
00051|messenger_core|DBG:Sent string of length 39 socket 0x8e536c0
00052|messenger_core|DBG:TCP socket connection accepted
00053|messenger_core|DBG:Copy 74 bytes to message
00054|messenger_core|DBG:Received packet of length 74
00055|jsonmessenger|DBG:JSON message of length 74
00056|jsonmessenger|DBG:Message posted as JSONMsg_event
<- after that I would expect the
output of my callback (the two print instruction)
00057|jsonmessenger|DBG:JSON:
{"MAC":"08:00:27:cc:77:1c","IP":"10.0.10.2","MSG":"Connection setup"}
00058|messenger_core|DBG:Copy 22 bytes to message
00059|messenger_core|DBG:Received packet of length 22
00060|jsonmessenger|DBG:JSON message of length 22
00061|jsonmessenger|DBG:Message posted as JSONMsg_event

00062|jsonmessenger|DBG:JSON: {"type":"disconnect"}
00063|jsonmessenger|DBG:Clear connection state for 0x8e536c0
{u'type': u'disconnect'}
{u'type': u'disconnect'}


So, the question is: Why my callback does not handle events posted by
jsonmessenger? How can I fix that? Is there any particular syntax I have to
follow so that it is a json-related error?

Thanks in advance.

Regards,
Giorgio



On 27/01/2012 16:42, kk yap wrote:

Hi Giorgio,

Your client is disconnecting before the reply is sent.  If you look at
nox-console.py, it should be a good example to follow.

Regards
KK

On 27 January 2012 05:12, Kyriakos Zarifis  wrote:

A JSONMsg_event is just another NOX event and us such it will either passed
on to all components down the event handler chain or stopped by one of them.
Your handler needs to return a valid NOX event disposition (
http://noxrepo.org/noxwiki/index.php/Disposition  )
So in your case you just need to add a "return STOP" and the error will
disappear.


As for the other comment, I'm not sure how messenger_core cleans the
connections state/closes socket. It might very well be a timing issue, maybe
the connection state hasn't been cleaned when the event is processed. I
don't know if the log messages represent the reality 100%. In any case the
last message is either never really sent or it's sent to the void. Either
way I'd just ignore it, I doubt it will affect anything


On Fri, Jan 27, 2012 at 3:02 AM, Giorgio Mazza
wrote:

I tried this way:  I replaced zaku's default messenger folder with
destiny's messenger one (nox/src/nox/coreapps/messenger), that I had
previously downloaded and installed.
Then I recompiled zaku and the import error disappeared, so that when I
run
./nox_core -v -i ptcp:6633 jsonmessenger=tcpport=3334 my_component
I do not get errors anymore and components are installed successfully.
However, when I try to send a json message from my external application I
get a strange behaviour. I don'

[nox-dev] ENVI+lavi flow display problem

2012-01-29 Thread wunyuan

Dear all,
I build a topology as follows:

NOX
   / \
   OF1OF2
/   \
   client1client2

In this environment, I configure client1 and client2 to ping each other 
and then I add request flow code in ENVI. First, I input "./nox_core -i 
ptcp:6633 lavitest_showflows" to run zaku version NOX. Second, I start 
translate python program to communicate with the modified ENVI. But I 
cannot see any flow in ENVI UI. I observe the translate program have 
received the flow request from ENVI but no reply message from lavi. I 
have some problems about lavi.


1.Can the LAVI in zaku version NOX receive and handle the flow requests 
from ENVI?


2.I know the lavitest_showflows have to call lavi_networkflow, but 
"lavi_networkflow::send_list(const Msg_stream& stream)" function is not 
called. If the LAVI in zaku version NOX can receive and handle the flow 
requests, could you tell me which function will be used to call 
"lavi_networkflow::send_list" when translate program send ENVI flow 
request successfully?


Thanks!

Best regard
Wun-Yuan

--

===
系統與網路技術組-黃文源(Wun-Yuan Huang)
財團法人國家實驗研究院
國家高速網路與計算中心南部事業群
National Center for High-Performance Computing South Region Office
台南縣台南科學園區南科三路28號
No.28, Nan-Ke 3rd. Rd., Science-based Industrial Park, Tainan 744, Taiwan, 
R.O.C.
TEL:06-5050940 ext.751
FAX:06-5050945
E-Mail:wuny...@nchc.narl.org.tw
===

___
nox-dev mailing list
nox-dev@noxrepo.org
http://noxrepo.org/mailman/listinfo/nox-dev