using crochet with autobahn but with standalone=False

#1

Hi,

I’ve run successfully crochet+autbahn example2 (modified to receive data from serial port instead from Flask). But with default wamp.run(“standalone=True”). Whenever i tried to standalone=False, and running another crossbar instance, i got error:

INFO: failing WebSocket opening handshake (‘WebSocket connection upgrade failed (200 - OK)’)
INFO: connection to tcp4:127.0.0.1:8080 lost
INFO: Stopping factory <autobahn.twisted.websocket.WampWebSocketClientFactory instance at 0x106d4b3b0>

``

This is my “working” script(standalone = True)

#!/usr/bin/env python

from future import print_function

import logging

from crochet import setup, run_in_reactor, wait_for

setup()

from autobahn.twisted.wamp import Application

from gsmmodem.serial_comms import SerialComms

PORT = ‘/dev/sms1’

BAUDRATE = 9600

wapp = Application()

@wapp.register(‘com.example.echome’)

def echome(data):

print(“echome() called with {}”.format(data))

return data

if name == ‘main’:

logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.DEBUG)

modem = SerialComms(PORT, BAUDRATE, notifyCallbackFunc=echome)

modem.RX_EOL_SEQ = '\n'

modem.connect()

@run_in_reactor

def start_wamp():

    wapp.run("ws://localhost:8080", "realm1", standalone = True, start_reactor = False, debug=False)

start_wamp()

try:

    modem.rxThread.join(2**31)

finally:

    modem.close();

``

The, if i change the standalone mode (standalone = False) + crossbar init’ed with empty config, the error above happen

this is my “empty” .crossbar config:

{

“controller”: {

},

“workers”: [

{

“type”: “router”,

“realms”: [

{

“name”: “realm1”,

“roles”: [

{

“name”: “anonymous”,

“permissions”: [

{

“uri”: “*”,

“publish”: true,

“subscribe”: true,

“call”: true,

“register”: true

}

]

}

]

}

],

“transports”: [

{

“type”: “web”,

“endpoint”: {

“type”: “tcp”,

“port”: 8080

},

“paths”: {

“/”: {

“type”: “static”,

“directory”: “…”

},

“ws”: {

“type”: “websocket”

}

}

}

]

}

]

}

``

Any hint’s how to use crochet with standalone crossbar ?

Regards,

Sayid Munawar

0 Likes

#2

apologize, i’ve found a solution, though i don’t know the what happen really. Changing crossbar’s transport type from “web” to “websocket” solve this issue

{

“controller”: {

},

“workers”: [

  {

     "type": "router",

     "realms": [

        {

           "name": "realm1",

           "roles": [

              {

                 "name": "anonymous",

                 "permissions": [

                    {

                       "uri": "*",

                       "publish": true,

                       "subscribe": true,

                       "call": true,

                       "register": true

                    }

                 ]

              }

           ]

        }

     ],

     "transports": [

        {

           "type": "websocket",

           "endpoint": {

              "type": "tcp",

              "port": 8080

           }

        }

     ]

  }

]

}

``

···

On Tuesday, November 18, 2014 2:14:04 AM UTC+7, Sayid Munawar wrote:

Hi,

I’ve run successfully crochet+autbahn example2 (modified to receive data from serial port instead from Flask). But with default wamp.run(“standalone=True”). Whenever i tried to standalone=False, and running another crossbar instance, i got error:

INFO: failing WebSocket opening handshake (‘WebSocket connection upgrade failed (200 - OK)’)
INFO: connection to tcp4:127.0.0.1:8080 lost
INFO: Stopping factory <autobahn.twisted.websocket.WampWebSocketClientFactory instance at 0x106d4b3b0>

``

This is my “working” script(standalone = True)

#!/usr/bin/env python

from future import print_function

import logging

from crochet import setup, run_in_reactor, wait_for

setup()

from autobahn.twisted.wamp import Application

from gsmmodem.serial_comms import SerialComms

PORT = ‘/dev/sms1’

BAUDRATE = 9600

wapp = Application()

@wapp.register(‘com.example.echome’)

def echome(data):

print(“echome() called with {}”.format(data))

return data

if name == ‘main’:

logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.DEBUG)
modem = SerialComms(PORT, BAUDRATE, notifyCallbackFunc=echome)
modem.RX_EOL_SEQ = '\n'
modem.connect()
@run_in_reactor
def start_wamp():
    wapp.run("ws://localhost:8080", "realm1", standalone = True, start_reactor = False, debug=False)
start_wamp()
try:
    modem.rxThread.join(2**31)
finally:
    modem.close();

``

The, if i change the standalone mode (standalone = False) + crossbar init’ed with empty config, the error above happen

this is my “empty” .crossbar config:

{

“controller”: {

},

“workers”: [

{

“type”: “router”,

“realms”: [

{

“name”: “realm1”,

“roles”: [

{

“name”: “anonymous”,

“permissions”: [

{

“uri”: “*”,

“publish”: true,

“subscribe”: true,

“call”: true,

“register”: true

}

]

}

]

}

],

“transports”: [

{

“type”: “web”,

“endpoint”: {

“type”: “tcp”,

“port”: 8080

},

“paths”: {

“/”: {

“type”: “static”,

“directory”: “…”

},

“ws”: {

“type”: “websocket”

}

}

}

]

}

]

}

``

Any hint’s how to use crochet with standalone crossbar ?

Regards,

Sayid Munawar

0 Likes

#3

Sayid,

two things:

a) when running standalone = True, this will already run a router, so you don't need another router (Crossbar.io). Use standalone = False for running with Crossbar.io

b) when using the Web transport, this will expose the WAMP-over-WebSocket at the URL

"ws://localhost:8080/ws"

not

"ws://localhost:8080"

(at least that is what the default config does). You need to use the former URL in your WAMP client to connect to. The error you get is because the latter URL only speaks HTTP (for serving static Web stuff), not WebSocket.

Hope this helps,
/Tobias

···

Am 17.11.2014 21:57, schrieb Sayid Munawar:

apologize, i've found a solution, though i don't know the what happen
really. Changing crossbar's transport type from "web" to "websocket"
solve this issue

>

{
    "controller": {
    },
    "workers": [
       {
          "type": "router",
          "realms": [
             {
                "name": "realm1",
                "roles": [
                   {
                      "name": "anonymous",
                      "permissions": [
                         {
                            "uri": "*",
                            "publish": true,
                            "subscribe": true,
                            "call": true,
                            "register": true
                         }
                      ]
                   }
                ]
             }
          ],
          "transports": [
             {
                "type": "websocket",
                "endpoint": {
                   "type": "tcp",
                   "port": 8080
                }
             }
          ]
       }
    ]
}
>

On Tuesday, November 18, 2014 2:14:04 AM UTC+7, Sayid Munawar wrote:

    Hi,

    I've run successfully crochet+autbahn example2 (modified to receive
    data from serial port instead from Flask). But with default
    wamp.run("standalone=True"). Whenever i tried to standalone=False,
    and running another crossbar instance, i got error:

    >
    INFO:failing WebSocketopening handshake ('WebSocket connection
    upgrade failed (200 - OK)')
    INFO:connection to tcp4:127.0.0.1:8080lost
    INFO:Stoppingfactory
    <autobahn.twisted.websocket.WampWebSocketClientFactoryinstance at
    0x106d4b3b0>
    >

    This is my "working" script(standalone = True)
    >
    #!/usr/bin/env python
    from __future__ import print_function

    import logging
    from crochet import setup, run_in_reactor, wait_for
    setup()

    from autobahn.twisted.wamp import Application
    from gsmmodem.serial_comms import SerialComms

    PORT = '/dev/sms1'
    BAUDRATE = 9600

    wapp = Application()

    @wapp.register('com.example.echome')
    def echome(data):
        print("echome() called with {}".format(data))
        return data

    if __name__ == '__main__':
         logging.basicConfig(format='%(levelname)s: %(message)s',
    level=logging.DEBUG)
         modem = SerialComms(PORT, BAUDRATE, notifyCallbackFunc=echome)
         modem.RX_EOL_SEQ = '\n'
         modem.connect()

         @run_in_reactor
         def start_wamp():
             wapp.run("ws://localhost:8080", "realm1", standalone =
    True, start_reactor = False, debug=False)

         start_wamp()

         try:
             modem.rxThread.join(2**31)
         finally:
             modem.close();

    >

    The, if i change the standalone mode (standalone = False) + crossbar
    init'ed with empty config, the error above happen

    this is my "empty" .crossbar config:
    >
    {
        "controller": {
        },
        "workers": [
           {
              "type": "router",
              "realms": [
                 {
                    "name": "realm1",
                    "roles": [
                       {
                          "name": "anonymous",
                          "permissions": [
                             {
                                "uri": "*",
                                "publish": true,
                                "subscribe": true,
                                "call": true,
                                "register": true
                             }
                          ]
                       }
                    ]
                 }
              ],
              "transports": [
                 {
                    "type": "web",
                    "endpoint": {
                       "type": "tcp",
                       "port": 8080
                    },
                    "paths": {
                       "/": {
                          "type": "static",
                          "directory": ".."
                       },
                       "ws": {
                          "type": "websocket"
                       }
                    }
                 }
              ]
           }
        ]
    }
    >

    Any hint's how to use crochet with standalone crossbar ?

    Regards,

    Sayid Munawar

--
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/1dc376ce-84ef-4e74-899a-fa0fda8a0e89%40googlegroups.com
<https://groups.google.com/d/msgid/autobahnws/1dc376ce-84ef-4e74-899a-fa0fda8a0e89%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

0 Likes

#4

I see,

thank you Tobias, good work on autobahn !

···

On Thu, Nov 20, 2014 at 3:49 PM, Tobias Oberstein tobias.o...@gmail.com wrote:

Sayid,

two things:

a) when running standalone = True, this will already run a router, so you don’t need another router (Crossbar.io). Use standalone = False for running with Crossbar.io

b) when using the Web transport, this will expose the WAMP-over-WebSocket at the URL

“ws://localhost:8080/ws”

not

“ws://localhost:8080”

(at least that is what the default config does). You need to use the former URL in your WAMP client to connect to. The error you get is because the latter URL only speaks HTTP (for serving static Web stuff), not WebSocket.

Hope this helps,

/Tobias

Am 17.11.2014 21:57, schrieb Sayid Munawar:

apologize, i’ve found a solution, though i don’t know the what happen

really. Changing crossbar’s transport type from “web” to “websocket”

solve this issue

|

{

"controller": {

},

"workers": [

   {

      "type": "router",

      "realms": [

         {

            "name": "realm1",

            "roles": [

               {

                  "name": "anonymous",

                  "permissions": [

                     {

                        "uri": "*",

                        "publish": true,

                        "subscribe": true,

                        "call": true,

                        "register": true

                     }

                  ]

               }

            ]

         }

      ],

      "transports": [

         {

            "type": "websocket",

            "endpoint": {

               "type": "tcp",

               "port": 8080

            }

         }

      ]

   }

]

}

|

On Tuesday, November 18, 2014 2:14:04 AM UTC+7, Sayid Munawar wrote:

Hi,



I've run successfully crochet+autbahn example2 (modified to receive

data from serial port instead from Flask). But with default

wamp.run("standalone=True"). Whenever i tried to standalone=False,

and running another crossbar instance, i got error:



|

INFO:failing WebSocketopening handshake ('WebSocket connection

upgrade failed (200 - OK)')

INFO:connection to tcp4:127.0.0.1:8080lost

INFO:Stoppingfactory

<autobahn.twisted.websocket.WampWebSocketClientFactoryinstance at


0x106d4b3b0>

|



This is my "working" script(standalone = True)

|

#!/usr/bin/env python

from __future__ import print_function



import logging

from crochet import setup, run_in_reactor, wait_for

setup()



from autobahn.twisted.wamp import Application

from gsmmodem.serial_comms import SerialComms



PORT = '/dev/sms1'

BAUDRATE = 9600



wapp = Application()



@wapp.register('com.example.echome')

def echome(data):

    print("echome() called with {}".format(data))

    return data



if __name__ == '__main__':

     logging.basicConfig(format='%(levelname)s: %(message)s',

level=logging.DEBUG)

     modem = SerialComms(PORT, BAUDRATE, notifyCallbackFunc=echome)

     modem.RX_EOL_SEQ = '\n'

     modem.connect()



     @run_in_reactor

     def start_wamp():

         wapp.run("ws://localhost:8080", "realm1", standalone =

True, start_reactor = False, debug=False)



     start_wamp()



     try:

         modem.rxThread.join(2**31)

     finally:

         modem.close();



|



The, if i change the standalone mode (standalone = False) + crossbar

init'ed with empty config, the error above happen



this is my "empty" .crossbar config:

|

{

    "controller": {

    },

    "workers": [

       {

          "type": "router",

          "realms": [

             {

                "name": "realm1",

                "roles": [

                   {

                      "name": "anonymous",

                      "permissions": [

                         {

                            "uri": "*",

                            "publish": true,

                            "subscribe": true,

                            "call": true,

                            "register": true

                         }

                      ]

                   }

                ]

             }

          ],

          "transports": [

             {

                "type": "web",

                "endpoint": {

                   "type": "tcp",

                   "port": 8080

                },

                "paths": {

                   "/": {

                      "type": "static",

                      "directory": ".."

                   },

                   "ws": {

                      "type": "websocket"

                   }

                }

             }

          ]

       }

    ]

}

|





Any hint's how to use crochet with standalone crossbar ?



Regards,



Sayid Munawar

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+unsubscribe@googlegroups.com

mailto:autobahnws+unsub...@googlegroups.com.

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

mailto:autobahnws@googlegroups.com.

To view this discussion on the web visit

https://groups.google.com/d/msgid/autobahnws/1dc376ce-84ef-4e74-899a-fa0fda8a0e89%40googlegroups.com

<https://groups.google.com/d/msgid/autobahnws/1dc376ce-84ef-4e74-899a-fa0fda8a0e89%40googlegroups.com?utm_medium=email&utm_source=footer>.

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

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+unsubscribe@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/546DAB02.8060101%40gmail.com.

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

0 Likes