Skip to content

HTTP Pusher Service

Tobias Oberstein edited this page Jun 11, 2014 · 24 revisions
pip install crossbarconnect

Create a sample configuration and code snippets:

mkdir $HOME/test1
cd $HOME/test1
crossbar init --template pusher

This will create the following files:

./.crossbar
./.crossbar/config.json
./publish.py
./publish_signed.py
./README.md
./web
./web/autobahn.min.js
./web/index.html

Now start Crossbar:

crossbar start

and open http://localhost:8080 in your browser. Open the JavaScript console to see events received.

Now you can publish events from Python by doing:

python publish.py

or for signed requests:

python publish_signed.py
{
   "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": "../web"
                  },
                  "ws": {
                     "type": "websocket"
                  },
                  "push": {
                     "type": "pusher",
                     "realm": "realm1",
                     "role": "anonymous",
                     "options": {
                        "debug": true
                     }
                  },
                  "pushsigned": {
                     "type": "pusher",
                     "realm": "realm1",
                     "role": "anonymous",
                     "options": {
                        "key": "foobar",
                        "secret": "secret",
                        "post_body_limit": 8192,
                        "timestamp_delta_limit": 10,
                        "require_ip": ["192.168.1.1/255.255.255.0", "127.0.0.1"],
                        "require_tls": false
                     }
                  }
               }
            }
         ]
      }
   ]
}
Clone this wiki locally