Hi All,
I don't know if I'm using in the right way this lib, but seems that something is missed.
Here the code of my simple Python client:
`import salesforce_streaming_client as sfclient
import time
import logging
logging.basicConfig(filename='out.log',level=logging.DEBUG)
def onMessage():
print "An event arrived"
new_callback_function = lambda new_name: onMessage()
client= sfclient.SalesforceStreamingClient(
oauth_client_id="3MVG9I5UQ_0k_hTm1tiC8kORoabEs.2KFt0oBgXo5gjOpeIeS7lgpgaoIMNKvUhuv4E5tXTSqcrW7ynO6nzI3",
client_secret="1738847514339357499",
username="XXXXXXXXXXXXXXX",
settings_path=None,
sandbox=False,
local_server_settings=('localhost', 60443),
password="XXXXXXXXXXXXXXXX",
ignore_cached_refresh_tokens=False,
version="41.0",
replay_client_id="0001",
cleanup_datadir=True)
some=client.handshake()
print some
client.subscribe(
channel="/event/Device_Action_Event__e",
callback=new_callback_function,
replay=True,
autocreate=True)
while 1:
time.sleep(1)
`
And this is the log content during and after the client execution
##########################################
DEBUG:requests_oauthlib.oauth2_session:Encoding client_id "3MVG9I5UQ_0k_hTm1tiC8kORoabEs.2KFt0oBgXo5gjOpeIeS7lgpgaoIMNKvUhuv4E5tXTSqcrW7ynO6nzI3" with client_secret as Basic auth credentials.
DEBUG:requests_oauthlib.oauth2_session:Requesting url https://login.salesforce.com/services/oauth2/token using method POST.
DEBUG:requests_oauthlib.oauth2_session:Supplying headers {u'Content-Type': u'application/x-www-form-urlencoded;charset=UTF-8', u'Accept': u'application/json'} and data {u'username': u'XXXXXXXXX', u'grant_type': u'password', u'redirect_uri': u'https://localhost:60443', u'client_id': u'3MVG9I5UQ_0k_hTm1tiC8kORoabEs.2KFt0oBgXo5gjOpeIeS7lgpgaoIMNKvUhuv4E5tXTSqcrW7ynO6nzI3', u'client_secret': u'1738847514339357499', u'password': u'XXXXXXXXXXXXX'}
DEBUG:requests_oauthlib.oauth2_session:Passing through key word arguments {'verify': True, 'json': None, 'proxies': None, 'timeout': None, 'auth': <requests.auth.HTTPBasicAuth object at 0x95a1f2c>}.
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): login.salesforce.com
DEBUG:urllib3.connectionpool:https://login.salesforce.com:443 "POST /services/oauth2/token HTTP/1.1" 200 None
DEBUG:requests_oauthlib.oauth2_session:Prepared fetch token request body grant_type=password&username=nguarnacci%40ppm.enel&redirect_uri=https%3A%2F%2Flocalhost%3A60443&client_id=3MVG9I5UQ_0k_hTm1tiC8kORoabEs.2KFt0oBgXo5gjOpeIeS7lgpgaoIMNKvUhuv4E5tXTSqcrW7ynO6nzI3&client_secret=1738847514339357499&password=salesforce1kqSZnsRVkXseP3TqOl0RU5pX
DEBUG:requests_oauthlib.oauth2_session:Request to fetch token completed with status 200.
DEBUG:requests_oauthlib.oauth2_session:Request headers were {'Content-Length': '270', 'Accept-Encoding': 'gzip, deflate', 'Accept': u'application/json', 'User-Agent': 'python-requests/2.18.4', 'Connection': 'keep-alive', 'Content-Type': u'application/x-www-form-urlencoded;charset=UTF-8', 'Authorization': 'Basic M01WRzlJNVVRXzBrX2hUbTF0aUM4a09Sb2FiRXMuMktGdDBvQmdYbzVnak9wZUllUzdsZ3BnYW9JTU5LdlVodXY0RTV0WFRTcWNyVzd5bk82bnpJMzoxNzM4ODQ3NTE0MzM5MzU3NDk5'}
DEBUG:requests_oauthlib.oauth2_session:Request body was username=nguarnacci%40ppm.enel&grant_type=password&redirect_uri=https%3A%2F%2Flocalhost%3A60443&client_id=3MVG9I5UQ_0k_hTm1tiC8kORoabEs.2KFt0oBgXo5gjOpeIeS7lgpgaoIMNKvUhuv4E5tXTSqcrW7ynO6nzI3&client_secret=1738847514339357499&password=salesforce1kqSZnsRVkXseP3TqOl0RU5pX
DEBUG:requests_oauthlib.oauth2_session:Response headers were {'X-XSS-Protection': '1; mode=block', 'X-Content-Type-Options': 'nosniff', 'Content-Security-Policy': 'upgrade-insecure-requests', 'Content-Encoding': 'gzip', 'Transfer-Encoding': 'chunked', 'Set-Cookie': 'BrowserId=b5cJYZ3yRlyqw30QZL0TOQ;Path=/;Domain=.salesforce.com;Expires=Sun, 11-Mar-2018 10:42:17 GMT;Max-Age=5184000', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains', 'Vary': 'Accept-Encoding', 'X-ReadOnlyMode': 'false', 'Cache-Control': 'no-cache,must-revalidate,max-age=0,no-store,private', 'Date': 'Wed, 10 Jan 2018 10:42:17 GMT', 'Content-Type': 'application/json;charset=UTF-8', 'Expires': 'Thu, 01 Jan 1970 00:00:00 GMT'} and content {"access_token":"00D0O000000ZkSU!ARcAQFI3kRYeblhaa1veEx2Jw70NGpky.I9n8GUI2cXSF.ltF.x84NYE04z2hC3YnAp7CHDKmLqmuc4dUoeruwsucFiNYaoZ","instance_url":"https://enelppm.my.salesforce.com","id":"https://login.salesforce.com/id/00D0O000000ZkSUUA0/0050O000007Sm31QAC","token_type":"Bearer","issued_at":"1515580938021","signature":"rFu5Qr5sgYnyPmwfhfqL/zEb0D6WlWz+1elXu+iZRvQ="}.
DEBUG:requests_oauthlib.oauth2_session:Invoking 0 token response hooks.
DEBUG:requests_oauthlib.oauth2_session:Obtained token {u'token_type': u'Bearer', u'issued_at': u'1515580938021', u'signature': u'rFu5Qr5sgYnyPmwfhfqL/zEb0D6WlWz+1elXu+iZRvQ=', u'access_token': u'00D0O000000ZkSU!ARcAQFI3kRYeblhaa1veEx2Jw70NGpky.I9n8GUI2cXSF.ltF.x84NYE04z2hC3YnAp7CHDKmLqmuc4dUoeruwsucFiNYaoZ', u'instance_url': u'https://enelppm.my.salesforce.com', u'id': u'https://login.salesforce.com/id/00D0O000000ZkSUUA0/0050O000007Sm31QAC'}.
INFO:python_bayeux:_send_message(): payload: {'ext': {'replay': True}, 'version': '1.0', 'channel': '/meta/handshake', 'supportedConnectionTypes': ['long-polling'], 'id': '1', 'minimumVersion': '1.0'} kwargs: {}
DEBUG:requests_oauthlib.oauth2_session:Invoking 0 protected resource request hooks.
DEBUG:requests_oauthlib.oauth2_session:Adding token {u'token_type': u'Bearer', u'issued_at': u'1515580938021', u'signature': u'rFu5Qr5sgYnyPmwfhfqL/zEb0D6WlWz+1elXu+iZRvQ=', u'access_token': u'00D0O000000ZkSU!ARcAQFI3kRYeblhaa1veEx2Jw70NGpky.I9n8GUI2cXSF.ltF.x84NYE04z2hC3YnAp7CHDKmLqmuc4dUoeruwsucFiNYaoZ', u'instance_url': u'https://enelppm.my.salesforce.com', u'id': u'https://login.salesforce.com/id/00D0O000000ZkSUUA0/0050O000007Sm31QAC'} to request.
DEBUG:requests_oauthlib.oauth2_session:Requesting url https://enelppm.my.salesforce.com/cometd/41.0/ using method POST.
DEBUG:requests_oauthlib.oauth2_session:Supplying headers {u'Authorization': u'Bearer 00D0O000000ZkSU!ARcAQFI3kRYeblhaa1veEx2Jw70NGpky.I9n8GUI2cXSF.ltF.x84NYE04z2hC3YnAp7CHDKmLqmuc4dUoeruwsucFiNYaoZ'} and data {"ext": {"replay": true}, "version": "1.0", "channel": "/meta/handshake", "supportedConnectionTypes": ["long-polling"], "id": "1", "minimumVersion": "1.0"}
DEBUG:requests_oauthlib.oauth2_session:Passing through key word arguments {'json': None}.
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): enelppm.my.salesforce.com
DEBUG:urllib3.connectionpool:https://enelppm.my.salesforce.com:443 "POST /cometd/41.0/ HTTP/1.1" 200 228
INFO:python_bayeux:_send_message(): response status code: 200 response.text: [{"ext":{"replay":true,"payload.format":true},"minimumVersion":"1.0","clientId":"13l1uaz5a53s9isw15x44ywf5zm6h","supportedConnectionTypes":["long-polling"],"channel":"/meta/handshake","id":"1","version":"1.0","successful":true}]
INFO:python_bayeux:_send_message(): payload: {'clientId': u'13l1uaz5a53s9isw15x44ywf5zm6h', 'connectionType': 'long-polling', 'channel': '/meta/connect', 'id': '2'} kwargs: {'timeout': None}
DEBUG:requests_oauthlib.oauth2_session:Invoking 0 protected resource request hooks.
DEBUG:requests_oauthlib.oauth2_session:Adding token {u'token_type': u'Bearer', u'issued_at': u'1515580938021', u'signature': u'rFu5Qr5sgYnyPmwfhfqL/zEb0D6WlWz+1elXu+iZRvQ=', u'access_token': u'00D0O000000ZkSU!ARcAQFI3kRYeblhaa1veEx2Jw70NGpky.I9n8GUI2cXSF.ltF.x84NYE04z2hC3YnAp7CHDKmLqmuc4dUoeruwsucFiNYaoZ', u'instance_url': u'https://enelppm.my.salesforce.com', u'id': u'https://login.salesforce.com/id/00D0O000000ZkSUUA0/0050O000007Sm31QAC'} to request.
DEBUG:requests_oauthlib.oauth2_session:Requesting url https://enelppm.my.salesforce.com/cometd/41.0/ using method POST.
DEBUG:requests_oauthlib.oauth2_session:Supplying headers {u'Authorization': u'Bearer 00D0O000000ZkSU!ARcAQFI3kRYeblhaa1veEx2Jw70NGpky.I9n8GUI2cXSF.ltF.x84NYE04z2hC3YnAp7CHDKmLqmuc4dUoeruwsucFiNYaoZ'} and data {"clientId": "13l1uaz5a53s9isw15x44ywf5zm6h", "connectionType": "long-polling", "channel": "/meta/connect", "id": "2"}
DEBUG:requests_oauthlib.oauth2_session:Passing through key word arguments {'json': None, 'timeout': None}.
DEBUG:urllib3.connectionpool:https://enelppm.my.salesforce.com:443 "POST /cometd/41.0/ HTTP/1.1" 200 160
INFO:python_bayeux:_send_message(): response status code: 200 response.text: [{"clientId":"13l1uaz5a53s9isw15x44ywf5zm6h","advice":{"interval":0,"timeout":110000,"reconnect":"retry"},"channel":"/meta/connect","id":"2","successful":true}]
INFO:python_bayeux:_send_message(): payload: {'ext': {'replay': True}, 'version': '1.0', 'channel': '/meta/handshake', 'supportedConnectionTypes': ['long-polling'], 'id': '1', 'minimumVersion': '1.0'} kwargs: {}
DEBUG:requests_oauthlib.oauth2_session:Invoking 0 protected resource request hooks.
DEBUG:requests_oauthlib.oauth2_session:Adding token {u'token_type': u'Bearer', u'issued_at': u'1515580938021', u'signature': u'rFu5Qr5sgYnyPmwfhfqL/zEb0D6WlWz+1elXu+iZRvQ=', u'access_token': u'00D0O000000ZkSU!ARcAQFI3kRYeblhaa1veEx2Jw70NGpky.I9n8GUI2cXSF.ltF.x84NYE04z2hC3YnAp7CHDKmLqmuc4dUoeruwsucFiNYaoZ', u'instance_url': u'https://enelppm.my.salesforce.com', u'id': u'https://login.salesforce.com/id/00D0O000000ZkSUUA0/0050O000007Sm31QAC'} to request.
DEBUG:requests_oauthlib.oauth2_session:Requesting url https://enelppm.my.salesforce.com/cometd/41.0/ using method POST.
DEBUG:requests_oauthlib.oauth2_session:Supplying headers {u'Authorization': u'Bearer 00D0O000000ZkSU!ARcAQFI3kRYeblhaa1veEx2Jw70NGpky.I9n8GUI2cXSF.ltF.x84NYE04z2hC3YnAp7CHDKmLqmuc4dUoeruwsucFiNYaoZ'} and data {"ext": {"replay": true}, "version": "1.0", "channel": "/meta/handshake", "supportedConnectionTypes": ["long-polling"], "id": "1", "minimumVersion": "1.0"}
DEBUG:requests_oauthlib.oauth2_session:Passing through key word arguments {'json': None}.
DEBUG:urllib3.connectionpool:https://enelppm.my.salesforce.com:443 "POST /cometd/41.0/ HTTP/1.1" 200 227
INFO:python_bayeux:_send_message(): response status code: 200 response.text: [{"ext":{"replay":true,"payload.format":true},"minimumVersion":"1.0","clientId":"13mnj1dh0rqgrzd1ixo0sru5zhe1","supportedConnectionTypes":["long-polling"],"channel":"/meta/handshake","id":"1","version":"1.0","successful":true}]
INFO:python_bayeux:_send_message(): payload: {'clientId': u'13mnj1dh0rqgrzd1ixo0sru5zhe1', 'connectionType': 'long-polling', 'channel': '/meta/connect', 'id': '2'} kwargs: {'timeout': None}
DEBUG:requests_oauthlib.oauth2_session:Invoking 0 protected resource request hooks.
DEBUG:requests_oauthlib.oauth2_session:Adding token {u'token_type': u'Bearer', u'issued_at': u'1515580938021', u'signature': u'rFu5Qr5sgYnyPmwfhfqL/zEb0D6WlWz+1elXu+iZRvQ=', u'access_token': u'00D0O000000ZkSU!ARcAQFI3kRYeblhaa1veEx2Jw70NGpky.I9n8GUI2cXSF.ltF.x84NYE04z2hC3YnAp7CHDKmLqmuc4dUoeruwsucFiNYaoZ', u'instance_url': u'https://enelppm.my.salesforce.com', u'id': u'https://login.salesforce.com/id/00D0O000000ZkSUUA0/0050O000007Sm31QAC'} to request.
DEBUG:requests_oauthlib.oauth2_session:Requesting url https://enelppm.my.salesforce.com/cometd/41.0/ using method POST.
DEBUG:requests_oauthlib.oauth2_session:Supplying headers {u'Authorization': u'Bearer 00D0O000000ZkSU!ARcAQFI3kRYeblhaa1veEx2Jw70NGpky.I9n8GUI2cXSF.ltF.x84NYE04z2hC3YnAp7CHDKmLqmuc4dUoeruwsucFiNYaoZ'} and data {"clientId": "13mnj1dh0rqgrzd1ixo0sru5zhe1", "connectionType": "long-polling", "channel": "/meta/connect", "id": "2"}
DEBUG:requests_oauthlib.oauth2_session:Passing through key word arguments {'json': None, 'timeout': None}.
DEBUG:urllib3.connectionpool:https://enelppm.my.salesforce.com:443 "POST /cometd/41.0/ HTTP/1.1" 200 159
INFO:python_bayeux:_send_message(): response status code: 200 response.text: [{"clientId":"13mnj1dh0rqgrzd1ixo0sru5zhe1","advice":{"interval":0,"timeout":110000,"reconnect":"retry"},"channel":"/meta/connect","id":"2","successful":true}]
INFO:python_bayeux:enqueueing subscription for channel /event/Device_Action_Event__e
####################################################################
Seems all works fine but nothing append when I throw an event from Salesforce side on the that topic channel (considering that another client wrote in Java subscribed at the same time to the same topic works fine).
Could you help me to understand?