noisyboiler / wampy

Websocket RPC and Pub/Sub for Python applications and microservices
Mozilla Public License 2.0
127 stars 24 forks source link

How to connect to a router, which is not on the same host ?! #39

Closed manatlan closed 7 years ago

manatlan commented 7 years ago

In all your examples, you make similars connexions like that :

c=Client(router=Crossbar())

But, this works only when the client is on the same host as the router (because it seems it feeds it with the local crossbar config). I don't have found a way to connect from a different machine ?! Is it possible with this wampy ?

noisyboiler commented 7 years ago

Hi @manatlan Thanks for your question. I'll add to the docs a more complete example. But yes, it's quite possible. It's all determined by your config of Crossbar.

E.g. http://wampy.readthedocs.io/en/latest/a_wampy_client.html See the default for localhost configured here: https://github.com/noisyboiler/wampy/blob/master/wampy/peers/routers.py#L19 Which points at what Crossbar.io would consider a default location. Here is the configuration for localhost: https://github.com/noisyboiler/wampy/blob/master/wampy/testing/configs/crossbar.json#L35

When I get a little time later this week I'll update master and readthedocs and catch up with you to make sure you have had success.

I've tested this myself with an instance of Crossbar running here: http://wampy.online/

Hope this helps. Short answer: It's all in the Crossbar configuration file

manatlan commented 7 years ago

But yes, it's quite possible. It's all determined by your config of Crossbar.

Yes, it's all the problem ;-) My client is on another host, where there is no crossbar config.json at all.

So I try to fake it, by doing something like that :

class Fake:
    pass

c=Fake()
c.host="manatlan.myhost.fr"
c.port=10001
c.realm="realm1"
c.can_use_tls=True
c.url="wss://manatlan.myhost.fr:10001/ws"
c.ipv=4

with Client(router=c) as client:

But, got :

cannot connect to: "wss://manatlan.myhost.fr:10001/ws": no suitable implementation for this system

I'm investigating on that; currently

It could be really cool to have something like the wampy js project, as simple as :

    var client = new Wampy('wss://manatlan.myhost.fr:10001/ws', { realm: "realm1" } )
noisyboiler commented 7 years ago

your current error sounds like the python 2.7 issue linked to at the bottom of this PR: https://github.com/noisyboiler/wampy/pull/37

will take on board your suggestion.