ofxTwitter
ofxTwitter copied to clipboard
tweet doesn't arrive in real time
the tweets doesn't arrive in real time and if i use in tracks not common words doesn't find nothing in the stream and disconnect after few minutes
Could you provide some code or other information ? I don't have any way to test our reproduce this problem without more specific information.
ok i try to explain myself better. When i use some common words like "roma" in setTrack function i have more or less 20 tweets all together after one minute from starts application and next 20 tweets again after more or less one minutes. When i use more uncommon words like "DDD2017" and i wrote a tweet with this word the stream doesn't find nothing and disconnected after more or less one minute
The Twitter Streaming API doesn't garantee that it will return all Tweets. If you want to capture your Tweet, use the REST search interface.
I'm not sure about why it disconnects. Are you using the latest version of the add-on?
it disconnect because streamingclient joint to timeout . tried with java twitter api ( twitter4j ) and it pullout instantantly the tweets. it is possible that one of addons required for ofxtwitter has some bugs?
Can you post the Twitter 4j code that works and the ofxTwitter code that is giving different results? It's certainly possible there are bugs in this addon but I need your help to systematically reproduce the bugs.
On Wed, May 3, 2017, 8:47 AM viniciolindo [email protected] wrote:
it disconnect because streamingclient joint to timeout . tried with java twitter api ( twitter4j ) and it pullout instantantly the tweets. it is possible that one of addons required for ofxtwitter has some bugs?
— You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/bakercp/ofxTwitter/issues/10#issuecomment-298915573, or mute the thread https://github.com/notifications/unsubscribe-auth/AASVxO9uPOmTyuFKugvC_Di6bZhr2N3xks5r2IVogaJpZM4NN6Uy .
the open frameworks code is your example_basic_streaming_filter with different keywords this is a simple code with processing
`String keywords[] = {"ddd2017" };
///////////////////////////// End Variable Config ////////////////////////////
TwitterStream twitter = new TwitterStreamFactory().getInstance();
PImage img; PImage imgUser; boolean imageLoaded; String textTwit; String nameUser; int counter;
void setup() { size(800, 600); noStroke(); imageMode(CENTER);
connectTwitter(); twitter.addListener(listener); if (keywords.length==0) twitter.sample(); else twitter.filter(new FilterQuery().track(keywords));
textTwit=""; nameUser="";
imgUser= createImage(66, 66, RGB); counter=0; setupXml(); }
void draw() { background(0); if (imageLoaded) { image(img, width/2, height/2); }
text(textTwit,10,10); text(nameUser,10,100);
image(imgUser, width/2, height/2);
}
// Initial connection void connectTwitter() { twitter.setOAuthConsumer(OAuthConsumerKey, OAuthConsumerSecret); AccessToken accessToken = loadAccessToken(); twitter.setOAuthAccessToken(accessToken); }
// Loading up the access token private static AccessToken loadAccessToken() { return new AccessToken(AccessToken, AccessTokenSecret); }
// This listens for new tweet
// Twitter doesn't recognize images from other sites as media, so must be parsed manually // You can add more services at the top if something is missing
String parseTwitterImg(String pageUrl) {
for (int i=0; i<imageService.length; i++) { if (pageUrl.startsWith(imageService[i][0])) {
String fullPage = ""; // container for html
String lines[] = loadStrings(pageUrl); // load html into an array, then move to container
for (int j=0; j < lines.length; j++) {
fullPage += lines[j] + "\n";
}
String[] pieces = split(fullPage, imageService[i][1]);
pieces = split(pieces[1], "\"");
return(pieces[0]);
}
} return(null); }`
In my opinion your addons works like a buffer of tweet to fill up before publish the tweets. If the buffer doesn't fill before timeout the stream disconnect
Did you find a solution? I am having a similar problem - I cannot filter the stream for my test tweets.
I have been looking into the streaming API and have had similar problems. Using specific track tags without much traffic eg. #formyevent would cause a timeout disconnect. Looking into the ofxTwitter one can enable stalls to prevent this as detailed on the API reference, however this happens "at a maximum rate of 5 minutes" while the twitter description requires for a re-connection every 90 seconds.
Set a timer, either a 90 second TCP level socket timeout, or a 90 second application level timer on the receipt of new data. If 90 seconds pass with no data received, including newlines, disconnect and reconnect immediately according to the backoff strategies in the next section.
Once an established connection drops, attempt to reconnect immediately.
Back off linearly for TCP/IP level network errors. These problems are generally temporary and tend to clear quickly. Increase the delay in reconnects by 250ms each attempt, up to 16 seconds.
Back off exponentially for HTTP errors for which reconnecting would be appropriate. Start with a 5 second wait, doubling each attempt, up to 320 seconds.
Back off exponentially for HTTP 420 errors. Start with a 1 minute wait and double each attempt. Note that every HTTP 420 received increases the time you must wait until rate limiting will no longer will be in effect for your account.
How would one build a re connection procedure using this description? Or would it be easier to change the stall time to the described 90s? I am using the latest version of this add on and all requirement addons with ofx Github build from 201803