Crossbar.io/Autobahn Transport lost when trying to call RPC from new class Python

#1

Hi Marko,

without being able to look at the whole code, here is my best guest:

You are trying to do things on the ApplicationSession not from the main thread, but a background thread. Or in the other direction.

This is possible, but requires use of some specific method (see below).

I therefor suggest that you first try to get familiar with Autobahn and ApplicationSesssion without any threads involved, and only then progress to what you actually want to do.

The specifics I was talking about are describe here:

http://twistedmatrix.com/documents/current/core/howto/threading.html

eg to call ApplicationSession.call() from a background thread, you need to use callFromThread.

This isn't an Autobahn thing, but a Twisted thing.

Hope above tips get you a bit further,
Cheers,
/Tobias

···

Am 11.04.2016 um 18:33 schrieb Marko Štumberger:

I had set the Crossbar router and wrote remote procedures, one of them
is write to db.

After i wrote client it worked ok, if i call from onJoin function, but
now i have a new class which should update the database but when i call
function to write to DB i get an error

"raise exception.TransportLost()"

client (not the full code):

>class Component(ApplicationSession): @inlineCallbacks def onJoin(self,
details): def start(json_data): t1 = TV_play() th1 =
threading.Thread(name='TV 1', target=t1.play, args=(1, 32001))
th1.start() yield self.register(start, u'si.nazvezi.play') def
update_status(self, Playlist_name, Beebox_id, TV_id, current_id): try:
print("Updating status",) self.call(u'si.nazvezi.setCurrentlyPlaying',
Playlist_name, Beebox_id, TV_id , current_id) return("OK updated the
status",) except: return("Failed to update the status") class
TV_play(Component): def play (self, TV_id, port)
Component.update_status(self, source['details']['Playlist_name'],
source['details']['BeeBoxID'], source['details']['TV_id'],
source['play_order']) |

so when i run this i get:

>2016-04-11T16:34:31+0200 Exception in thread TV 1:
2016-04-11T16:34:31+0200 Traceback (most recent call last):
2016-04-11T16:34:31+0200 File "/usr/lib/python2.7/threading.py", line
810, in __bootstrap_inner 2016-04-11T16:34:31+0200 self.run()
2016-04-11T16:34:31+0200 Traceback (most recent call last):
2016-04-11T16:34:31+0200 File "/usr/lib/python2.7/threading.py", line
810, in __bootstrap_inner 2016-04-11T16:34:31+0200 self.run()
2016-04-11T16:34:31+0200 File "/usr/lib/python2.7/threading.py", line
763, in run 2016-04-11T16:34:31+0200 self.__target(*self.__args,
**self.__kwargs) 2016-04-11T16:34:31+0200 File
"/home/marko/Desktop/client/testcall.py", line 167, in play
2016-04-11T16:34:31+0200 Component.update_status(self,
source['details']['Playlist_name'], source['details']['BeeBoxID'],
source['details']['TV_id'], source['play_order'])
2016-04-11T16:34:31+0200 File "/home/marko/Desktop/client/testcall.py",
line 113, in update_status 2016-04-11T16:34:31+0200
self.call(u'si.nazvezi.setCurrentlyPlaying', Playlist_name, Beebox_id,
TV_id , current_id) 2016-04-11T16:34:31+0200 File
"/home/marko/.local/lib/python2.7/site-packages/autobahn/wamp/protocol.py",
line 1229, in call 2016-04-11T16:34:31+0200 raise
exception.TransportLost() 2016-04-11T16:34:31+0200 TransportLost |

I tried to use super and tried also
runner.run(Component),runner.run(TV_play) but nothing seems to work. So
my question is: what must I make, to be able to call rpc procedures from
another class.

Regards from Slovenia, Marko

--
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
<mailto:autobahnws+...@googlegroups.com>.
To post to this group, send email to autob...@googlegroups.com
<mailto:autob...@googlegroups.com>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/autobahnws/8a1549d9-4a90-4d06-83bc-b5339b56e17a%40googlegroups.com
<https://groups.google.com/d/msgid/autobahnws/8a1549d9-4a90-4d06-83bc-b5339b56e17a%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

0 Likes

#2

I’m sorry… i had to delete it. it was work related …

i figured out a way to make it work with creating a class inside of ApplicationSession works fine now :slight_smile:

thanks for helping Tobias.

Regards from Slovenia

0 Likes