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

Setting includeReplies to nil fails in user streams #44

Closed
inb4ohnoes opened this issue Nov 9, 2013 · 9 comments
Closed

Setting includeReplies to nil fails in user streams #44

inb4ohnoes opened this issue Nov 9, 2013 · 9 comments

Comments

@inb4ohnoes
Copy link
Contributor

I'm calling

[api getUserStreamDelimited:@NO stallWarnings:@YES includeMessagesFromFollowedAccounts:nil includeReplies:nil keywordsToTrack:nil locationBoundingBoxes:nil progressBlock:progressBlock stallWarningBlock:stallWarningBlock errorBlock:errorBlock];

and it returns a timeout error. I might be mistaken but isn't setting includeReplies to nil supposed to return only mutual follow replies as described in the Streaming API docs?

@nst
Copy link
Owner

nst commented Nov 10, 2013

I cannot reproduce the issue. I just tried with TweetDeck consumer tokens and XAuth and requested the user stream as you did. I immediately get a dictionary with a single 'friends' key. When the user posts something, I immediately receive the tweet. Please ensure to be using the latest version. Also, ensure your consumer tokens are allowed to use the streaming API. If it still doesn't work, please consider making a sample, minimal project that I can run and debug. Thank you.

@inb4ohnoes
Copy link
Contributor Author

Hmm. I'll check again, but setting it to @yES returns everything just fine, all replies of everybody included. Setting it to nil gets the same results as before. I'll report back when i try again.

@nst
Copy link
Owner

nst commented Nov 10, 2013

In order to ease your tests, you may want to run this code:

STTwitterAPI *api = [STTwitterAPI twitterAPIWithOAuthConsumerKey:TWEET_DECK_CK
                                                  consumerSecret:TWEET_DECK_CS
                                                        username:USERNAME
                                                        password:PASSWORD];

[api verifyCredentialsWithSuccessBlock:^(NSString *username) {

    [api getUserStreamDelimited:@NO stallWarnings:@YES includeMessagesFromFollowedAccounts:nil includeReplies:nil keywordsToTrack:nil locationBoundingBoxes:nil progressBlock:^(id response) {
        NSLog(@"-- response: %@", response);
    } stallWarningBlock:^(NSString *code, NSString *message, NSUInteger percentFull) {
        NSLog(@"-- code: %@, message: %@", code, message);
    } errorBlock:^(NSError *error) {
        NSLog(@"-- error 2: %@", [error localizedDescription]);
    }];

} errorBlock:^(NSError *error) {
    NSLog(@"-- error 1: %@", [error localizedDescription]);
}];

This is what I get here:

2013-11-10 01:55:01.304 STTwitterDemoOSX[27454:303] -- response: {
    friends =     (
        108527800
    );
}
2013-11-10 01:55:12.841 STTwitterDemoOSX[27454:303] -- response: {
    contributors = "<null>";
    coordinates = "<null>";
    "created_at" = "Sun Nov 10 00:55:15 +0000 2013";
    entities =     {
        hashtags =         (
        );
        symbols =         (
        );
        urls =         (
        );
        "user_mentions" =         (
        );
    };
    "favorite_count" = 0;
    favorited = 0;
    "filter_level" = medium;
    geo = "<null>";
    id = 399339434098692096;
    "id_str" = 399339434098692096;
    "in_reply_to_screen_name" = "<null>";
    "in_reply_to_status_id" = "<null>";
    "in_reply_to_status_id_str" = "<null>";
    "in_reply_to_user_id" = "<null>";
    "in_reply_to_user_id_str" = "<null>";
    lang = und;
    place = "<null>";
    "retweet_count" = 0;
    retweeted = 0;
    source = web;
    text = asd;
    truncated = 0;
    user =     {
        "contributors_enabled" = 0;
        "created_at" = "Sun Mar 24 08:42:41 +0000 2013";
        "default_profile" = 1;
        "default_profile_image" = 0;
        description = "<null>";
        "favourites_count" = 1;
        "follow_request_sent" = "<null>";
        "followers_count" = 1;
        following = "<null>";
        "friends_count" = 1;
        "geo_enabled" = 1;
        id = 1294332967;
        "id_str" = 1294332967;
        "is_translator" = 0;
        lang = en;
        "listed_count" = 0;
        location = "";
        name = "nst022 test account";
        notifications = "<null>";
        "profile_background_color" = C0DEED;
        "profile_background_image_url" = "http://abs.twimg.com/images/themes/theme1/bg.png";
        "profile_background_image_url_https" = "https://abs.twimg.com/images/themes/theme1/bg.png";
        "profile_background_tile" = 0;
        "profile_image_url" = "http://pbs.twimg.com/profile_images/378800000192809050/6a5b12e3e227e4ca8afb2de89a416f2e_normal.gif";
        "profile_image_url_https" = "https://pbs.twimg.com/profile_images/378800000192809050/6a5b12e3e227e4ca8afb2de89a416f2e_normal.gif";
        "profile_link_color" = 0084B4;
        "profile_sidebar_border_color" = C0DEED;
        "profile_sidebar_fill_color" = DDEEF6;
        "profile_text_color" = 333333;
        "profile_use_background_image" = 1;
        protected = 0;
        "screen_name" = nst022;
        "statuses_count" = 34;
        "time_zone" = Amsterdam;
        url = "<null>";
        "utc_offset" = 3600;
        verified = 0;
    };
}

@inb4ohnoes
Copy link
Contributor Author

I tried the above in the demo project, replacing the keys with mine, and it still errors out. I do have the latest version of STTwitter. I also tried using the demo app's keys, and the same thing still happens.

Here is what's returned:

2013-11-09 20:32:48.299 STTwitterDemoiOS[5056:70b] -- regexError: (null)
2013-11-09 20:32:48.299 STTwitterDemoiOS[5056:70b] -- body: (null)
2013-11-09 20:32:48.299 STTwitterDemoiOS[5056:70b] -- error 2: The request timed out.

Am I missing something regarding how my app is supposed to be set up in Twitter's application settings?

@nst
Copy link
Owner

nst commented Nov 10, 2013

The streaming API is not available to all applications, but you said your application was able to use it.

I uploaded a working test project using TweetDeck tokens http://seriot.ch/temp/STTwitterStreaming.zip.

You should get the stream after entering your login and password.

If it still doesn't work, then maybe you IP is temporarily banned for some reason. Try to print the response headers.

Also, maybe you have a special character in your password or something?

We'll find out :-)

@inb4ohnoes
Copy link
Contributor Author

I changed my password to the simplest password123 i could think of to eliminate special characters, ran the project after inserting my user/pass, and guess what? Same error! However, when i went back to my project and tried again, I managed to get two streamed tweets back, then the same error, running on device, on LTE (unlimited data, and not on my home network). I've made sure i'm not calling the method multiple times or anything like that, so I don't think it's an IP ban thing as wouldn't that also affect the stream where all replies are included? For the record, this is the error in full I get back

2013-11-10 10:08:21.113 Nightingale[780:60b] error: Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo=0x181c82f0 {NSErrorFailingURLStringKey=https://userstream.twitter.com/1.1/user.json?stall_warnings=1&stringify_friend_ids=1&delimited=0, NSErrorFailingURLKey=https://userstream.twitter.com/1.1/user.json?stall_warnings=1&stringify_friend_ids=1&delimited=0, NSLocalizedDescription=The request timed out., NSUnderlyingError=0x16e815f0 "The request timed out."}

Edit: Could it be an NSURLCache issue? I do have a cache set up in my app, but it should only cache images...
I'm also calling the streaming method in the completion block of the getHomeTimeline method. Would this be an issue?

@nst
Copy link
Owner

nst commented Nov 10, 2013

Ok so I think the problem is not related to the includeReplies parameter but to the timeout parameter in STHTTPRequest which is, by default, set to 30 seconds. In fact, I've never waited for so long while testing the streaming API. I will remove this timeout for streaming requests. Meanwhile, you can set the kSTHTTPRequestDefaultTimeout value to zero and hopefully you won't get timeouts anymore. Thank you for spotting this issue and helping me to find out the cause.

@nst
Copy link
Owner

nst commented Nov 10, 2013

I removed the timeout for all requests ac58d48.

@inb4ohnoes
Copy link
Contributor Author

Yes it's fixed! Thank you for your support, I would probably not have thought it was a timing problem! 👍

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