Possible issue with v2 API streaming?
riney opened this issue · 2 comments
riney commented
Hello - thanks for providing the library. I think I've found a potential issue with the new V2 API support.
If I run the examples/v2/stream_tweets.py
sample, it successfully connects, sets rules, and starts receiving tweets. However, after about 20 seconds, it errors out with the following:
WARNING:root:<class 'json.decoder.JSONDecodeError'> Expecting value: line 1 column 1 (char 0)
Expecting value: line 1 column 1 (char 0)
I enabled requests/urllib3 debug logging to see what's happening with the underlying connection. That resulted in the following:
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.twitter.com:443
send: b'GET /2/tweets/search/stream HTTP/1.1\r\nHost: api.twitter.com\r\nAccept-Encoding: identity\r\nUser-Agent: python-TwitterAPI\r\nAuthorization: Bearer [removed]\r\n\r\n'
reply: 'HTTP/1.1 200 OK\r\n'
header: cache-control: no-cache, no-store, max-age=0
header: date: Sun, 21 Feb 2021 04:18:02 GMT
header: server: tsa_a
header: set-cookie: personalization_id=[removed]"; Max-Age=63072000; Expires=Tue, 21 Feb 2023 04:18:02 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None
header: set-cookie: guest_id=[removed]; Max-Age=63072000; Expires=Tue, 21 Feb 2023 04:18:02 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None
header: strict-transport-security: max-age=631138519
header: transfer-encoding: chunked
header: x-access-level: read
header: x-connection-hash: d60ccdd629e6357adb732beda1ab84f8
header: x-content-type-options: nosniff
header: x-frame-options: SAMEORIGIN
header: x-rate-limit-limit: 50
header: x-rate-limit-remaining: 49
header: x-rate-limit-reset: 1613881982
header: x-response-time: 55
header: x-xss-protection: 0
DEBUG:urllib3.connectionpool:https://api.twitter.com:443 "GET /2/tweets/search/stream HTTP/1.1" 200 None
The initial connection isn't returning any bytes, which I think is expected, but looks like the source of the JSON parsing error. Any thoughts on this?
geduldig commented
Thanks for spotting that! Fixed now in v2.6.9
riney commented
It works perfectly now! Thank you.