Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Long Polling flow #6

Open
qctan opened this issue Nov 13, 2019 · 0 comments
Open

Long Polling flow #6

qctan opened this issue Nov 13, 2019 · 0 comments

Comments

@qctan
Copy link

qctan commented Nov 13, 2019

Hi @robertmrk

I'm trying using your library to receive notifications from a platform that only supports long-polling. I am rather new to Cometd but I did testing using the platform's example through Postman. It seems like the order of messages to set up that they are suggesting is /meta/handshake, /meta/subscribe, then /meta/connect, where the actual long-polling is held at the connect message until a notification is received.

However as I adapted your example to receive notifications from the platform, I can see the outgoing handshake message, followed by the incoming handshake message and finally the outgoing connect message where the long-polling is held. As the subscribe method is not
called until client is set up, I'm never able to receive any notification from the channel I'm interested in.

I am not sure if the order was defined in the protocol spec or whether there's something I've missed, but this is what I found in Salesforce's documentation (not the platform I'm referring to), where 'subscribe' happens before 'connect'.
https://developer.salesforce.com/docs/atlas.en-us.api_streaming.meta/api_streaming/using_streaming_api_client_connection.htm

Code:

async def chat():
    # connect to the server
    async with Client(f'https://platform.com/notifications', extensions=[MyExtension]) as client:
        
        await client.subscribe("/DecodedEventListener/trigger")
        
        # listen for incoming messages
        async for message in client:
            print(message)

Output:

Outgoing messages: [{'channel': <MetaChannel.HANDSHAKE: '/meta/handshake'>, 'version': '1.0', 'supportedConnectionTypes': ['websocket', 'long-polling'], 'minimumVersion': '1.0', 'id': '0'}]

response message: {'id': '0', 'minimumVersion': '1.0', 'supportedConnectionTypes': ['long-polling', 'smartrest-long-polling'], 'successful': True, 'channel': '/meta/handshake', 'ext': {'ack': True}, 'clientId': '2918jmzu83wu9gwi7av3thi1h5s', 'version': '1.0'}

Outgoing messages: [{'channel': <MetaChannel.CONNECT: '/meta/connect'>, 'clientId': '2918jmzu83wu9gwi7av3thi1h5s', 'connectionType': 'long-polling', 'id': '1'}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant