Skip to main content

Crossbar HTTP 3

https://travis-ci.org/jose-lpa/crossbarhttp3.svg?branch=master https://codecov.io/gh/jose-lpa/crossbarhttp3/branch/master/graph/badge.svg https://img.shields.io/pypi/v/crossbarhttp3.svg https://img.shields.io/pypi/l/crossbarhttp3.svg

Module that provides methods for accessing Crossbar.io HTTP Bridge Services

Fork of the original package by Eric Chapman at The HQ, now supporting Python 2.6, 2.7 and 3+ versions.

Installation

Install Crossbar HTTP 3 with pip:

pip install crossbarhttp3

Basic usage

Call

To call a Crossbar HTTP bridge, do the following:

client = Client('http://127.0.0.1/call')
result = client.call('com.example.add', 2, 3, offset=10)

This will call the following add_something method of an ApplicationSession object:

from autobahn.twisted.wamp import ApplicationSession
from twisted.internet.defer import inlineCallbacks


class MyComponent(ApplicationSession):
    @inlineCallbacks
    def onJoin(self, details):

        def add_something(x, y, offset=0):
            print('Add was called')
            return x + y + offset

        yield self.register(add_something, 'com.example.add')

Publish

To publish to a Crossbar HTTP bridge, do the following:

client = Client('http://127.0.0.1/publish')
result = client.publish('com.example.event', event='new event')

The receiving subscription implemented in an ApplicationSession class would look like this:

from autobahn.twisted.wamp import ApplicationSession
from twisted.internet.defer import inlineCallbacks


class MyComponent(ApplicationSession):
    @inlineCallbacks
    def onJoin(self, details):

        def subscribe_something(event=None, **kwargs):
            print('Publish was called with event %s' % event)

        yield self.subscribe(subscribe_something, 'com.example.event')

Key/Secret

For bridge services that have a key and secret defined, simply include the key and secret in the instantiation of the client.

client = Client('http://127.0.0.1/publish', key='key', secret='secret')

Additional options

There are two more options available in the client instantiation:

  • timeout: Lets you specify a number of seconds from which an idle request to the Crossbar.io node will be dismissed (timed out). Defaults to None, meaning that the global default timeout setting will be used.

  • silently: If set to True, any failed request to the Crossbar.io node will be returned by the client as None, without raising any exception. Defaults to False, meaning that all failures will raise their correspondent exceptions.

Exceptions

The library will throw the following exceptions. Note that all exceptions subclass from ClientBaseException so you can just catch that if you don’t want the granularity.

  • ClientBadUrl - The specified URL is not a HTTP bridge service

  • ClientBadHost - The specified host name is rejecting the connection

  • ClientMissingParams - The call was missing parameters

  • ClientSignatureError - The signature did not match

  • ClientNoCalleeRegistered - Callee was not registered on the router for the specified procedure

  • ClientCallRuntimeError - Procedure triggered an exception

Contributing

All bug-fixes or improvements to the library are welcome.

To contribute, fork the repo and submit a pull request to the develop branch. Please, try to follow this basic coding rules:

  • Always include some unit tests for the new code you write or the bugs you fix. Or, update the existent unit tests if necessary.

  • Stick to PEP-8 styling.

Testing

In order to test Crossbar HTTP 3 properly you must have a Crossbar.io node in HTTP Bridge mode running in localhost port 8001. You can do that by yourself if you need it, but otherwise there is a Docker image already prepared, so you don’t have to bother with this.

To use that image and raise a Docker container with everything working, make sure you have Docker installed and execute this command:

docker run -t -p 8001:8001 --name crossbar-bridge joselpa/crossbar-http-bridge:0.2

Then you can run the unit tests in the regular way:

python setup.py test

License

Released under MIT License.

Metadata

Release files for crossbarhttp3 1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for crossbarhttp3 1.1
File Size Uploaded Provenance Actions
crossbarhttp3-1.1.tar.gz 5.9 kB Without provenance Details for crossbarhttp3-1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for crossbarhttp3 1.1
File Interpreter ABI Platform Actions
crossbarhttp3-1.1-py2.py3-none-any.whl Python 2, Python 3 none any Details for crossbarhttp3-1.1-py2.py3-none-any.whl

Total release size: 11.7 kB

Release files / crossbarhttp3-1.1.tar.gz

Download URL crossbarhttp3-1.1.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
3bd1a1d868cfc05609a36320d9a8207049a66eb4fd9a535fb309f42453130dd4
BLAKE2b-256 checksum
How to use checksums
1e5d23e8ae3269ca91c9f515f32a14874b60c1ef96342ada6d7f831654d56183
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / crossbarhttp3-1.1-py2.py3-none-any.whl

Download URL crossbarhttp3-1.1-py2.py3-none-any.whl
Size 5.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
d03fb48a43523c01e6372eed40bcb1cb7b76e5024c5a7e8308c83fded99c6860
BLAKE2b-256 checksum
How to use checksums
f1d547df14de22c52d64c777b4a4be3f2de383a8b68a1e363163baffa087c95c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for crossbarhttp3 1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page