RouterSession instance has no attribute '_as_future' ?

#1

Hi all,

Any thought on the error that I’m getting when I do the following?

I’ve setup a WAMP server that way using Python (see below)

==============================================

Create WAMP router factory

router_factory = router.RouterFactory()

create a WAMP router session factory

session_factory = wamp.protocol.RouterSessionFactory(router_factory)

Register protocol

session_factory.add(protocol) # protocol is an instance of ApplicationSession

create a WAMP-over-WebSocket transport server factory

transport_factory = websocket.WampWebSocketServerFactory(session_factory, \

url = “%s://%s:%d” % (“ws”, “localhost”, 8080), \

debug = True, \

debug_wamp = True )

wsResource = resource.WebSocketResource(transport_factory)

root = File(’/…/www’)

root.putChild(“ws”, wsResource)

site = Site(root)

reactor.listenTCP(options.port, site)

reactor.run()

==============================================

Then on the client (WebBrowser) using the JS library I try to connect that way

// ==============================================

var connection = new autobahn.Connection({

url: ‘http://localhost:8080/ws’,

realm: “something similar than the server side realm”,

maxRetries: 0,

retryDelay: 2000

});

connection.onopen = function(session) {

try {

Store ref to session for my app

} catch(e) {

console.log(e);

}

}

connection.onerror = function(code,reason) {

console.log(code);

console.log(reason);

}

connection.open();

// ==============================================

I have the following error in the JavaScript console:

The connection to ws://localhost:8080/ws was interrupted while the page was loading.

And on the server I have the following output:

2014-06-13 10:44:18-0600 [-] Log opened.

2014-06-13 10:44:18-0600 [-] Site starting on 8080

2014-06-13 10:44:18-0600 [-] Starting factory <twisted.web.server.Site instance at 0x10c96f0e0>

2014-06-13 10:44:23-0600 [HTTPChannel,2,127.0.0.1]

[(‘debug’, True, ‘WampWebSocketServerFactory’),

(‘debugCodePaths’, False, ‘WampWebSocketServerFactory’),

(‘logOctets’, True, ‘WampWebSocketServerFactory’),

(‘logFrames’, True, ‘WampWebSocketServerFactory’),

(‘trackTimings’, False, ‘WampWebSocketServerFactory’),

(‘allowHixie76’, False, ‘WampWebSocketServerFactory’),

(‘utf8validateIncoming’, True, ‘WampWebSocketServerFactory’),

(‘applyMask’, True, ‘WampWebSocketServerFactory’),

(‘maxFramePayloadSize’, 0, ‘WampWebSocketServerFactory’),

(‘maxMessagePayloadSize’, 0, ‘WampWebSocketServerFactory’),

(‘autoFragmentSize’, 0, ‘WampWebSocketServerFactory’),

(‘failByDrop’, True, ‘WampWebSocketServerFactory’),

(‘echoCloseCodeReason’, False, ‘WampWebSocketServerFactory’),

(‘openHandshakeTimeout’, 5, ‘WampWebSocketServerFactory’),

(‘closeHandshakeTimeout’, 1, ‘WampWebSocketServerFactory’),

(‘tcpNoDelay’, True, ‘WampWebSocketServerFactory’),

(‘versions’, [0, 8, 13], ‘WampWebSocketServerFactory’),

(‘webStatus’, True, ‘WampWebSocketServerFactory’),

(‘requireMaskedClientFrames’, True, ‘WampWebSocketServerFactory’),

(‘maskServerFrames’, False, ‘WampWebSocketServerFactory’),

(‘perMessageCompressionAccept’,

<function at 0x10c36b8c0>,

‘WampWebSocketServerFactory’)]

2014-06-13 10:44:23-0600 [HTTPChannel,2,127.0.0.1] connection accepted from peer 127.0.0.1:54948

2014-06-13 10:44:23-0600 [HTTPChannel,2,127.0.0.1] RX Octets from 127.0.0.1:54948 : octets = 474554202f777320485454502f312e310d0a4f726967696e3a20687474703a2f2f6c6f63616c686f73743a383038300d0a557067726164653a20776562736f636b65740d0a4163636570742d4c616e67756167653a20656e2d55532c656e3b713d302e350d0a4163636570742d456e636f64696e673a20677a69702c206465666c6174650d0a5365632d576562736f636b65742d56657273696f6e3a2031330d0a5365632d576562736f636b65742d50726f746f636f6c3a2077616d702e322e6a736f6e0d0a436f6e6e656374696f6e3a206b6565702d616c6976652c20557067726164650d0a4163636570743a20746578742f68746d6c2c6170706c69636174696f6e2f7868746d6c2b786d6c2c6170706c69636174696f6e2f786d6c3b713d302e392c2a2f2a3b713d302e380d0a557365722d4167656e743a204d6f7a696c6c612f352e3020284d6163696e746f73683b20496e74656c204d6163204f5320582031302e393b2072763a32392e3029204765636b6f2f32303130303130312046697265666f782f32392e300d0a486f73743a206c6f63616c686f73743a383038300d0a5365632d576562736f636b65742d4b65793a207a6c47614351576d7053695533477a32534a564b37513d3d0d0a507261676d613a206e6f2d63616368650d0a43616368652d436f6e74726f6c3a206e6f2d63616368650d0a0d0a

2014-06-13 10:44:23-0600 [HTTPChannel,2,127.0.0.1] received HTTP request:

GET /ws HTTP/1.1

Origin: http://localhost:8080

Upgrade: websocket

Accept-Language: en-US,en;q=0.5

Accept-Encoding: gzip, deflate

Sec-Websocket-Version: 13

Sec-Websocket-Protocol: wamp.2.json

Connection: keep-alive, Upgrade

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8

User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:29.0) Gecko/20100101 Firefox/29.0

Host: localhost:8080

Sec-Websocket-Key: zlGaCQWmpSiU3Gz2SJVK7Q==

Pragma: no-cache

Cache-Control: no-cache

2014-06-13 10:44:23-0600 [HTTPChannel,2,127.0.0.1] received HTTP status line in opening handshake : GET /ws HTTP/1.1

2014-06-13 10:44:23-0600 [HTTPChannel,2,127.0.0.1] received HTTP headers in opening handshake : {u’origin’: u’http://localhost:8080’, u’upgrade’: u’websocket’, u’accept-language’: u’en-US,en;q=0.5’, u’accept-encoding’: u’gzip, deflate’, u’sec-websocket-version’: u’13’, u’sec-websocket-protocol’: u’wamp.2.json’, u’host’: u’localhost:8080’, u’accept’: u’text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8’, u’user-agent’: u’Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:29.0) Gecko/20100101 Firefox/29.0’, u’connection’: u’keep-alive, Upgrade’, u’sec-websocket-key’: u’zlGaCQWmpSiU3Gz2SJVK7Q==’, u’pragma’: u’no-cache’, u’cache-control’: u’no-cache’}

2014-06-13 10:44:23-0600 [HTTPChannel,2,127.0.0.1] sending HTTP response:

HTTP/1.1 101 Switching Protocols

Server: AutobahnPython/0.8.9

Upgrade: WebSocket

Connection: Upgrade

Sec-WebSocket-Protocol: wamp.2.json

Sec-WebSocket-Accept: JfLBmJZKDZXOcxPKSVZLW5M8d4s=

2014-06-13 10:44:23-0600 [HTTPChannel,2,127.0.0.1] TX Octets to 127.0.0.1:54948 : sync = False, octets = 485454502f312e312031303120537769746368696e672050726f746f636f6c730d0a5365727665723a204175746f6261686e507974686f6e2f302e382e390d0a557067726164653a20576562536f636b65740d0a436f6e6e656374696f6e3a20557067726164650d0a5365632d576562536f636b65742d50726f746f636f6c3a2077616d702e322e6a736f6e0d0a5365632d576562536f636b65742d4163636570743a204a664c426d4a5a4b445a584f6378504b53565a4c57354d386434733d0d0a0d0a

2014-06-13 10:44:23-0600 [HTTPChannel,2,127.0.0.1] RX Octets from 127.0.0.1:54948 : octets = 81fe015cbc97d0d1e7a6fcf3cae3bba6d9f5f2fdc7b5a2bed0f2a3f386ecf2b2ddfbbcb4ceb5eaaa9ef1b5b0c8e2a2b4cfb5eaaa9ef4b1bdd0f2a28ed5f3b5bfc8feb6b8dff6a4b8d3f9f2ebc8e5a5b490b5a0a3d3f0a2b4cfe4b9a7d9c8b3b0d0fb8fa3d9e4a5bdc8e4f2ebc8e5a5b4c1eafcf3dff6bcbdd9f2f2ebc7b5b6b4dde3a5a3d9e4f2ebc7b5a0a3d3f0a2b4cfe4b9a7d9c8b3b0d0fb8fa3d9e4a5bdc8e4f2ebc8e5a5b4c1eafcf3cce2b2bdd5e4b8b4ceb5eaaa9ef1b5b0c8e2a2b4cfb5eaaa9ee4a5b3cff4a2b8def2a28edefbb1b2d7e0b8b8c8f28fbdd5e4a4b8d2f0f2ebc8e5a5b490b5a0a4defbb9a2d4f2a28ed9efb3bdc9e4b9bed2b5eaa5cee2b5fd9ee7a5b3d0fea3b9d9e58fb8d8f2bea5d5f1b9b2dde3b9bed2b5eaa5cee2b5acc1bbf2a2c9f5a3b2cefeb2b4ceb5eaaa9ef1b5b0c8e2a2b4cfb5eaaa9ee7a5b3d0fea3b9d9e58fb8d8f2bea5d5f1b9b2dde3b9bed2b5eaa5cee2b5acc1eaad8c

2014-06-13 10:44:23-0600 [HTTPChannel,2,127.0.0.1] RX Frame from 127.0.0.1:54948 : fin = True, rsv = 0, opcode = 1, mask = bc97d0d1, length = 348, payload = [1,“realm1”,{“roles”:{“caller”:{“features”:{“caller_identification”:true,“progressive_call_results”:true}},“callee”:{“features”:{“progressive_call_results”:true}},“publisher”:{“features”:{“subscriber_blackwhite_listing”:true,“publisher_exclusion”:true,“publisher_identification”:true}},“subscriber”:{“features”:{“publisher_identification”:true}}}}]

2014-06-13 10:44:23-0600 [HTTPChannel,2,127.0.0.1] RX WAMP HELLO Message (realm = realm1, roles = [<autobahn.wamp.role.RoleSubscriberFeatures instance at 0x10c975998>, <autobahn.wamp.role.RolePublisherFeatures instance at 0x10c9759e0>, <autobahn.wamp.role.RoleCallerFeatures instance at 0x10c975a28>, <autobahn.wamp.role.RoleCalleeFeatures instance at 0x10c975a70>], authmethods = None)

2014-06-13 10:44:23-0600 [HTTPChannel,2,127.0.0.1] Traceback (most recent call last):

2014-06-13 10:44:23-0600 [HTTPChannel,2,127.0.0.1] File “/…/autobahn/wamp/websocket.py”, line 90, in onMessage

2014-06-13 10:44:23-0600 [HTTPChannel,2,127.0.0.1] self._session.onMessage(msg)

2014-06-13 10:44:23-0600 [HTTPChannel,2,127.0.0.1] File “/…/autobahn/wamp/protocol.py”, line 1218, in onMessage

2014-06-13 10:44:23-0600 [HTTPChannel,2,127.0.0.1] d = self._as_future(self.onHello, self._realm, details)

2014-06-13 10:44:23-0600 [HTTPChannel,2,127.0.0.1] AttributeError: RouterSession instance has no attribute ‘_as_future’

2014-06-13 10:44:23-0600 [HTTPChannel,2,127.0.0.1] Failing WAMP-over-WebSocket transport: code = 1011, reason = ‘WAMP Internal Error (RouterSession instance has no attribute ‘_as_future’)’

2014-06-13 10:44:23-0600 [-] WAMP-over-WebSocket transport lost: wasClean = False, code = 1006, reason = ‘connection was closed uncleanly (I failed the WebSocket connection by dropping the TCP connection)’

2014-06-13 10:44:23-0600 [-] connection from 127.0.0.1:54948 lost

Thanks,

Seb

0 Likes

#2

The issue was because of invalid import

from autobahn.wamp.router import RouterFactory

router_factory = RouterFactory()

create a WAMP router session factory

from autobahn.twisted.wamp import RouterSessionFactory

session_factory = RouterSessionFactory(router_factory)

Register protocol

session_factory.add(protocol)

create a WAMP-over-WebSocket transport server factory

from autobahn.twisted.websocket import WampWebSocketServerFactory

···

0 Likes

#3

Hi Seb,

ah, yes. You need to import the "twisted" or "asyncio" bits, not the

autobahn.wamp.X

which is generic/abstract code that is not yet adapted to Twisted or asyncio via mixins. User code then imports the concrete code from

autobahn.twisted.wamp.X

or

autobahn.asyncio.wamp.X

Those classes use the generic/abstract code and mixin their Twisted / asyncio specific bits.

/Tobias

···

Am 13.06.2014 19:34, schrieb Sebastien Jourdain:

The issue was because of invalid import

     from autobahn.wamp.router import RouterFactory
     router_factory = RouterFactory()

     # create a WAMP router session factory
     from autobahn.twisted.wamp import RouterSessionFactory
     session_factory = RouterSessionFactory(router_factory)

     # Register protocol
     session_factory.add(protocol)

     # create a WAMP-over-WebSocket transport server factory
     from autobahn.twisted.websocket import WampWebSocketServerFactory

    ...

--
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>.
For more options, visit https://groups.google.com/d/optout.

0 Likes