unbound method trying to publish to pubsub

#1

I’m working on a python client for a python autobahn pubsub. When the session is opened, it opens a second websocket to a gephi (http://www.gephi.org) server. The gephi server starts sending messages in gephi’s graph streaming format immediately on websocket connection.

When a message is received, I try and publish the message back to the pubsub server (which has a custom pub handler to save the graph objects in neo4j). On line 95 of the client (https://github.com/gdbassett/moirai/blob/master/clients/gephi_import/gephi_import.py) I am having trouble calling the function of the protocol handler. Instead, I am getting an unbound method error (“unbound method updateGraph() must be called with MyClientProtocol instance as first argument (got str instance instead)”). Does anyone have any suggestions on how to appropriately refer to the publish function (or any function) within the protocol handler from outside of it?

Thanks for the help!

Gabe

0 Likes

#2

I was able to get it to work by assigning the protocol to an object in main. I’m not sure if that’s the right way to do it or not, but it works. However, I’m hitting another problem. I keep getting an error on publish that the event isn’t serializable. As far as I can tell, it is because I am using json to load the string that comes from the gephi websocket into a dictionary. In doing so, the strings are converted to unicode which seems to cause the self.factory._serialize(msg) function at line 1387 in https://github.com/tavendo/AutobahnPython/blob/master/autobahn/autobahn/wamp.py to fail tripping the except a few lines later. Any thoughts on this one?

Gabe

···

On Thursday, February 28, 2013 1:15:47 PM UTC-6, Gabriel Bassett wrote:

I’m working on a python client for a python autobahn pubsub. When the session is opened, it opens a second websocket to a gephi (http://www.gephi.org) server. The gephi server starts sending messages in gephi’s graph streaming format immediately on websocket connection.

When a message is received, I try and publish the message back to the pubsub server (which has a custom pub handler to save the graph objects in neo4j). On line 95 of the client (https://github.com/gdbassett/moirai/blob/master/clients/gephi_import/gephi_import.py) I am having trouble calling the function of the protocol handler. Instead, I am getting an unbound method error (“unbound method updateGraph() must be called with MyClientProtocol instance as first argument (got str instance instead)”). Does anyone have any suggestions on how to appropriately refer to the publish function (or any function) within the protocol handler from outside of it?

Thanks for the help!

Gabe

0 Likes

#3

When I send the message with https://github.com/gdbassett/moirai/blob/master/clients/abtestclient2.py, it works fine. When I send the message with https://github.com/gdbassett/moirai/blob/master/clients/gephi_import/gephi_import.py, it fails. You can see the output from the two clients in https://github.com/gdbassett/moirai/blob/master/clients/compare_output.txt.

···

On Thursday, February 28, 2013 1:15:47 PM UTC-6, Gabriel Bassett wrote:

I’m working on a python client for a python autobahn pubsub. When the session is opened, it opens a second websocket to a gephi (http://www.gephi.org) server. The gephi server starts sending messages in gephi’s graph streaming format immediately on websocket connection.

When a message is received, I try and publish the message back to the pubsub server (which has a custom pub handler to save the graph objects in neo4j). On line 95 of the client (https://github.com/gdbassett/moirai/blob/master/clients/gephi_import/gephi_import.py) I am having trouble calling the function of the protocol handler. Instead, I am getting an unbound method error (“unbound method updateGraph() must be called with MyClientProtocol instance as first argument (got str instance instead)”). Does anyone have any suggestions on how to appropriately refer to the publish function (or any function) within the protocol handler from outside of it?

Thanks for the help!

Gabe

0 Likes

#4

It appears the line : “o = self.factory._serialize(msg)” in wamp.py is failing with error “MyClientProtocol instance has no attribute factory”. This is using the code at https://github.com/gdbassett/moirai/blob/master/clients/gephi_import/gephi_import.py. Any ideas?

···

On Thursday, February 28, 2013 9:18:37 PM UTC-6, Gabriel Bassett wrote:

When I send the message with https://github.com/gdbassett/moirai/blob/master/clients/abtestclient2.py, it works fine. When I send the message with https://github.com/gdbassett/moirai/blob/master/clients/gephi_import/gephi_import.py, it fails. You can see the output from the two clients in https://github.com/gdbassett/moirai/blob/master/clients/compare_output.txt.

On Thursday, February 28, 2013 1:15:47 PM UTC-6, Gabriel Bassett wrote:

I’m working on a python client for a python autobahn pubsub. When the session is opened, it opens a second websocket to a gephi (http://www.gephi.org) server. The gephi server starts sending messages in gephi’s graph streaming format immediately on websocket connection.

When a message is received, I try and publish the message back to the pubsub server (which has a custom pub handler to save the graph objects in neo4j). On line 95 of the client (https://github.com/gdbassett/moirai/blob/master/clients/gephi_import/gephi_import.py) I am having trouble calling the function of the protocol handler. Instead, I am getting an unbound method error (“unbound method updateGraph() must be called with MyClientProtocol instance as first argument (got str instance instead)”). Does anyone have any suggestions on how to appropriately refer to the publish function (or any function) within the protocol handler from outside of it?

Thanks for the help!

Gabe

0 Likes

#5

Not sure what you trying to do .. also: what library is imported on line

https://github.com/gdbassett/moirai/blob/master/clients/gephi_import/gephi_import.py#L13

??

0 Likes

#6

I’m trying to take a dictionary supplied from a websocket client (connected to a gephi streaming server, http://www.gephi.org), and publish the dictionary as an event to the autobahn server.

The ‘import websocket’ on line 13 is the python websocket-client module (https://github.com/liris/websocket-client, https://pypi.python.org/pypi/websocket-client/0.9.0).

I’m finding if I assign the protocol handler to a variable (“proto”) and try and call publish (proto.publish(msg)), I get that publish doesn’t have a factory attribute (used to do the serialization at line 1387 of wamp.py). If i try and call the factory (factory.protocol.publish(msg)) I get the error that publish is an unbound method.

···

On Friday, March 1, 2013 12:01:39 PM UTC-6, Tobias Oberstein wrote:

Not sure what you trying to do … also: what library is imported on line

https://github.com/gdbassett/moirai/blob/master/clients/gephi_import/gephi_import.py#L13

??

0 Likes

#7

I should point out that I updated wamp.py (lines 1388 & 1389) to give print out the actual exception. The currently raised exception that the event isn’t serializable (line 1389) isn’t accurate in this case.

···

On Friday, March 1, 2013 1:18:55 PM UTC-6, Gabriel Bassett wrote:

I’m trying to take a dictionary supplied from a websocket client (connected to a gephi streaming server, http://www.gephi.org), and publish the dictionary as an event to the autobahn server.

The ‘import websocket’ on line 13 is the python websocket-client module (https://github.com/liris/websocket-client, https://pypi.python.org/pypi/websocket-client/0.9.0).

I’m finding if I assign the protocol handler to a variable (“proto”) and try and call publish (proto.publish(msg)), I get that publish doesn’t have a factory attribute (used to do the serialization at line 1387 of wamp.py). If i try and call the factory (factory.protocol.publish(msg)) I get the error that publish is an unbound method.

On Friday, March 1, 2013 12:01:39 PM UTC-6, Tobias Oberstein wrote:

Not sure what you trying to do … also: what library is imported on line

https://github.com/gdbassett/moirai/blob/master/clients/gephi_import/gephi_import.py#L13

??

0 Likes

#8

I'm trying to take a dictionary supplied from a websocket client
(connected to a gephi streaming server, http://www.gephi.org), and

are you talking about

http://wiki.gephi.org/index.php/Graph_Streaming

?

with the announced ws api?

publish the dictionary as an event to the autobahn server.

as far as I can see it might be much simpler to create an Autobahn WAMP server that in addition connects to gephi via an embedded pure ws autobahn client. you can use "dispatch" on WAMP server factory to inject pubsub events into the broker.

The 'import websocket' on line 13 is the python websocket-client module
(https://github.com/liris/websocket-client, https://pypi.python.org/pypi/websocket-client/0.9.0).

why are you using another Python ws library? this introduces its own event loop, be more complicated to integrate .. and the stuff seems to be pretty alpha. Autobahn includes a full featured, tested pure ws client ..

I'm finding if I assign the protocol handler to a variable ("proto") and
try and call publish (proto.publish(msg)), I get that publish doesn't
have a factory attribute (used to do the serialization at line 1387 of
wamp.py). If i try and call the factory (factory.protocol.publish(msg))
I get the error that publish is an unbound method.

the whole program wont work for a couple of reasons .. starting with that you are using 2 different event loops.

anyway, I created a Gephi bridge which might be what you are looking for:

https://github.com/oberstet/scratchbox/tree/master/python/gephi

easier to code than to explain ..

let me know if that helps.

Tobias

···

Am 01.03.2013 20:18, schrieb Gabriel Bassett:

On Friday, March 1, 2013 12:01:39 PM UTC-6, Tobias Oberstein wrote:

    Not sure what you trying to do .. also: what library is imported on
    line

    https://github.com/gdbassett/moirai/blob/master/clients/gephi_import/gephi_import.py#L13
    <https://github.com/gdbassett/moirai/blob/master/clients/gephi_import/gephi_import.py#L13>

    ??

--
You received this message because you are subscribed to the Google
Groups "Autobahn" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to autobahnws+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Likes

#9

pls try the

https://github.com/oberstet/scratchbox/tree/master/python/gephi

example.

start the python proggy, point your browser to localhost:8080.

the proggy will contact your gephi server (with 5s delay) and publish everything it receives on a topic. the html/js client receives that stuff.

0 Likes

#10

Thank you for the example! I’ll give it a try.

Gabe

···

On Friday, March 1, 2013 3:11:39 PM UTC-6, Tobias Oberstein wrote:

pls try the

https://github.com/oberstet/scratchbox/tree/master/python/gephi

example.

start the python proggy, point your browser to localhost:8080.

the proggy will contact your gephi server (with 5s delay) and publish
everything it receives on a topic. the html/js client receives that stuff.

0 Likes

#11

Just so I know, is it possible to do a client-to-client type bridge? I’d prefer not to have to build capabilities like this into my server.

···

On Friday, March 1, 2013 3:19:08 PM UTC-6, Gabriel Bassett wrote:

Thank you for the example! I’ll give it a try.

Gabe

On Friday, March 1, 2013 3:11:39 PM UTC-6, Tobias Oberstein wrote:

pls try the

https://github.com/oberstet/scratchbox/tree/master/python/gephi

example.

start the python proggy, point your browser to localhost:8080.

the proggy will contact your gephi server (with 5s delay) and publish
everything it receives on a topic. the html/js client receives that stuff.

0 Likes

#12

Gabe,

···

Am 01.03.2013 22:48, schrieb Gabriel Bassett:

Just so I know, is it possible to do a client-to-client type bridge?
  I'd prefer not to have to build capabilities like this into my server.

sure. you will have to keep another wheel (the c2c bridge) running to make the whole system fly .. but it will work:

create an Autobahn WAMP client. in onSessionOpen(), create an Autobahn WS client connecting to gephi and set a reference to the outer WAMP client so you can forward WS messages and do the publish.

Tobias

0 Likes