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

Streaming API incomplete tweet #58

Open
bcambel opened this issue Dec 11, 2014 · 3 comments
Open

Streaming API incomplete tweet #58

bcambel opened this issue Dec 11, 2014 · 3 comments

Comments

@bcambel
Copy link

bcambel commented Dec 11, 2014

Hi Adam,

Great library, thank you very much!

I am having an issue where the received tweet stream is incomplete. In some cases, the stream is properly JSON parsed though. Here is the code that I use

(defn parse-tweet
  [resp tweet]
  (try 
    (let [tw-obj (parse-string tweet true)]
      (when (:text tw-obj)
        (log/info (select-keys tw-obj [:id :text]))))
    (catch Throwable t 
      (log/error (.getMessage t) (format "Can't parse tweet\n%s" tweet)))))

(defn vacuum-twttr [tracking]
  (statuses-filter :params {:track tracking}
             :oauth-creds my-creds
             :callbacks (AsyncStreamingCallback. 
                            (fn [resp tweet]
                                (parse-tweet resp (str tweet)))
                          (comp println response-return-everything)
                          exception-print)))

My assumption is that somehow using str over ByteArrayOutputStream creates the problem. Do you have any suggestions ?

Thanks a lot,
Bahadir

@adamwynne
Copy link
Owner

I think it being chunked by twitter - someone wrote some library (forgotten
which) that sits on top of mine and does the correct message chunking -
take a look at the issues and it should be there

On Thu, Dec 11, 2014 at 11:03 AM, Bahadir Cambel [email protected]
wrote:

Hi Adam,

Great library, thank you very much!

I am having an issue where the received tweet stream is incomplete. In
some cases, the stream is properly JSON parsed though. Here is the code
that I use

(defn parse-tweet
[resp tweet](try
%28let [tw-obj %28parse-string tweet true%29]
%28when %28:text tw-obj%29
%28log/info %28select-keys tw-obj [:id :text]%29%29%29%29
%28catch Throwable t
%28log/error %28.getMessage t%29 %28format "Can't parse tweetn%s" tweet)))))

(defn vacuum-twttr [tracking](statuses-filter :params {:track tracking}
:oauth-creds my-creds
:callbacks %28AsyncStreamingCallback.
%28fn [resp tweet]
%28parse-tweet resp %28str tweet%29%29%29
%28comp println response-return-everything%29
exception-print%29))

My assumption is that somehow using str over ByteArrayOutputStream
creates the problem. Do you have any suggestions ?

Thanks a lot,
Bahadir


Reply to this email directly or view it on GitHub
#58.

@bcambel
Copy link
Author

bcambel commented Dec 11, 2014

Thanks for the quick response Adam. For future reference, here is the library https://github.com/mccraigmccraig/twitter-streaming-client

@adamwynne
Copy link
Owner

thanks for pointing it out

On Thu, Dec 11, 2014 at 12:32 PM, Bahadir Cambel [email protected]
wrote:

Thanks for the quick response Adam. For future reference, here is the
library https://github.com/mccraigmccraig/twitter-streaming-client


Reply to this email directly or view it on GitHub
#58 (comment)
.

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

2 participants