Trying to get Crossbar Autobahn|Python to work with wss

#1

Hi all,

I have been trying to get a WSS connection going for a couple of days now and it hasn’t worked. Here’s what I’ve got:

Original working setup:

  • An internet browser (frontend) and an Arduino device (backend).

  • Code based on the serial2ws example where IoT is running serial2ws.py and the browser is running Autobahn.

  • A working system under ws://

New changes:

Certs: I’ve added server.crt and server.key into a /keys folder on the device.

Browser autobahn: I’ve got (simplified):

wsuri = (document.location.protocol === "http:" ? "ws:" : "wss:") + "//" + ip + ":" + port + "/ws";

connection = new autobahn.Connection({
    url: wsuri,
    realm: 'realm1'});

``

**Device serial2ws.py: **mostly as in the example, except for:

# at the top
  from twisted.internet import ssl

# in if __name__ == '__main__':
  contextFactory = ssl.DefaultOpenSSLContextFactory('/root/keys/server.key', '/root/keys/server.crt')

  parser.add_argument("--router", type=six.text_type, default=u'wss://localhost:8080/ws', help='WAMP router URL')

  runner = ApplicationRunner(router, args.realm, extra={'port': args.port, 'baudrate': args.baudrate, 'debug': args.debug}, standalone=not args.router, ssl=contextFactory)

``

Current Status

The python server exits with:

2016-07-01 20:13:15-0400 [-] Starting factory <twisted.web.server.Site instance at 0x76dcd1c0>
2016-07-01 20:13:15-0400 [-] SSLContextFactory: <twisted.internet.ssl.DefaultOpenSSLContextFactory instance at 0x76dcd4b8>
2016-07-01 20:13:15-0400 [-] Traceback (most recent call last):
2016-07-01 20:13:15-0400 [-] File “/root/serial2ws.py”, line 457, in
2016-07-01 20:13:15-0400 [-] standalone=not args.router, ssl=contextFactory) # Causes error if removed
2016-07-01 20:13:15-0400 [-] TypeError: init() got an unexpected keyword argument ‘ssl’

``

I’ve been trying LOTS of combinations of things and I’m not getting any luck yet. Any help would be greatly appreciated. Thank you!

0 Likes

#2

i don’t use twisted, i use asyncio, and if you’re willing to change things, take a look at one of my most recent projects. it’s all wss with proper certs. take a look at https://github.com/Blue-Labs/ButterflyDNS

···

On Sat, Jul 2, 2016 at 12:40 AM, sscirrus sanjee...@gmail.com wrote:

Hi all,

I have been trying to get a WSS connection going for a couple of days now and it hasn’t worked. Here’s what I’ve got:

Original working setup:

  • An internet browser (frontend) and an Arduino device (backend).
  • Code based on the serial2ws example where IoT is running serial2ws.py and the browser is running Autobahn.
  • A working system under ws://

New changes:

Certs: I’ve added server.crt and server.key into a /keys folder on the device.

Browser autobahn: I’ve got (simplified):

wsuri = (document.location.protocol === "http:" ? "ws:" : "wss:") + "//" + ip + ":" + port + "/ws";


connection = new autobahn.Connection({
    url: wsuri,
    realm: 'realm1'});

``

**Device serial2ws.py: **mostly as in the example, except for:

# at the top
  from twisted.internet import ssl

# in if __name__ == '__main__':
  contextFactory = ssl.DefaultOpenSSLContextFactory('/root/keys/server.key', '/root/keys/server.crt')

  parser.add_argument("--router", type=six.text_type, default=u'wss://localhost:8080/ws', help='WAMP router URL')

  runner = ApplicationRunner(router, args.realm, extra={'port': args.port, 'baudrate': args.baudrate, 'debug': args.debug}, standalone=not args.router, ssl=contextFactory)

``

Current Status

The python server exits with:

2016-07-01 20:13:15-0400 [-] Starting factory <twisted.web.server.Site instance at 0x76dcd1c0>
2016-07-01 20:13:15-0400 [-] SSLContextFactory: <twisted.internet.ssl.DefaultOpenSSLContextFactory instance at 0x76dcd4b8>
2016-07-01 20:13:15-0400 [-] Traceback (most recent call last):
2016-07-01 20:13:15-0400 [-] File “/root/serial2ws.py”, line 457, in
2016-07-01 20:13:15-0400 [-] standalone=not args.router, ssl=contextFactory) # Causes error if removed
2016-07-01 20:13:15-0400 [-] TypeError: init() got an unexpected keyword argument ‘ssl’

``

I’ve been trying LOTS of combinations of things and I’m not getting any luck yet. Any help would be greatly appreciated. Thank you!

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.

To post to this group, send email to autob...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/autobahnws/70500ef6-3eb5-4de2-b8be-6147759b33bb%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Gay/FireRescue/Geek in 33484, USA
It’s the ideals of Linux and Open Source that are amazing, it embodies what WE want, not what is marketed

0 Likes