noisyboiler / wampy

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

feature request: expose session timeout to Client & caller #78

Closed keiser1080 closed 5 years ago

keiser1080 commented 5 years ago

Hi,

I try to proxy do a wamp2 proxy to a slow rest api (response time > 10 seconde), I get constant timeout, because the timeout is hardcoded to 5 secondes in session.recv_message .

Could you add a Client scope timeout, and a caller, suscriber timeout?

class BinaryNumberService(Client):

    @callee(timeout=15)
    def get_binary_number(self, number):
        return bin(number)

not sure if we can change the client timeout when we subclassing the Client class?

and

with Client(timeout=15) as client:
    response = client.rpc.get_foobar()
noisyboiler commented 5 years ago

ah, bad show by me! sorry. yes, let's add this asap.

noisyboiler commented 5 years ago

I think this only makes sense on the Caller in terms of the protocol specs https://wamp-proto.org/_static/gen/wamp_latest.html#call-timeouts

keiser1080 commented 5 years ago

Hi, not sure to understand. In the first example (caller) without the timeout, If the call exceed the http timeout the caller will never receive the response. To test you can add sleep(15) before the return

noisyboiler commented 5 years ago

ah, I misunderstood. wampy implements its own "timeout", whilst WAMP does support it as part of the protocol..... but Crossbar i fear does not: https://github.com/crossbario/crossbar/issues/299

For now, wampy wins. PR to follow.

Thanls @keiser1080

keiser1080 commented 5 years ago

If I good understand the crossbar issue, is for another use case. It's in case of we want to set a limit, If the call is greater than for example 10 second.

The problem I am facing it's the exact opposite. I get a timeout because my micro service is a proxy to a very slow rest service.

So I get always a timeout.

Le lun. 31 déc. 2018 à 18:07, simon notifications@github.com a écrit :

ah, I misunderstood. wampy implements its own "timeout", whilst WAMP does support it as part of the protocol..... but Crossbar i fear does not: crossbario/crossbar#299 https://github.com/crossbario/crossbar/issues/299

For now, wampy wins. PR to follow.

Thanls @keiser1080 https://github.com/keiser1080

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/noisyboiler/wampy/issues/78#issuecomment-450669594, or mute the thread https://github.com/notifications/unsubscribe-auth/ABqDzVOiziGCzuZvvHVNJ9cy3WAHDIXVks5u-kRJgaJpZM4YpXRb .

noisyboiler commented 5 years ago

i've tried to solve both then, here: https://github.com/noisyboiler/wampy/pull/84/files

keiser1080 commented 5 years ago

Thanks I will check this asap.

Le lun. 31 déc. 2018 à 18:29, simon notifications@github.com a écrit :

i've tried to solve both then, here: https://github.com/noisyboiler/wampy/pull/84/files

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/noisyboiler/wampy/issues/78#issuecomment-450672022, or mute the thread https://github.com/notifications/unsubscribe-auth/ABqDzY3S_8pL2ky_NNjzy9W16hjYg0oZks5u-kl6gaJpZM4YpXRb .

noisyboiler commented 5 years ago

let me know how you get on.

keiser1080 commented 5 years ago

@noisyboiler i just installed wampy==0.9.20 using pipenv, in a fresh python environement And i still get the same issue .

message = async_adapter.receive_message(timeout=timeout) wampy.errors.WampProtocolError: no message returned (timed-out in 5)

here the sample service:

import datetime
from wampy.peers.clients import Client
from wampy.roles.callee import callee
import time
class DateService(Client):
    """ 
    slow date service
    """  
    @callee
    def get_slow(self):
        time.sleep(15)
        return datetime.date.today().isoformat()

there are no call_timeout argument in the client

what i am doing wrong?

edit: the wampy version 0.9.20 from pypi seems to be out of sync with the one hosted in github

https://github.com/noisyboiler/wampy/blob/master/wampy/peers/clients.py

noisyboiler commented 5 years ago

hiya. it's declared on the client __init__. https://github.com/noisyboiler/wampy/blob/master/wampy/peers/clients.py#L29

test case here: https://github.com/noisyboiler/wampy/blob/b1b0329f2ef392fd71d4097ed7a0cc1b75ff4db2/test/roles/test_callers.py#L138

noisyboiler commented 5 years ago

ah, yes! i need to do a release, sorry. https://github.com/noisyboiler/wampy/releases

still in draft status.

noisyboiler commented 5 years ago

will do asap

keiser1080 commented 5 years ago

This issue can be close. The timout work perfectly!

thanks again!