Unable to connect to the remote server when using Twitterizer


#1

Hello,

I have created a MVC application using Twitterizer. I am fetching Home Timeline using my code. The code works fine when running in VS 2012. Once I deploy it to IIS it goes bonkers & does not return any results. I tried to pull the details of error and found the following :

Error Message: Unable to connect to the remote server
Request URL: https://api.twitter.com/1.1/statuses/home_timeline.json
Result: ConnectionFailure

My code is as follows:

[HttpGet]
        public JsonResult GetTwitterFeed()
        {
            try
            {
                OAuthTokens tokens = new OAuthTokens();
                tokens.ConsumerKey = (string)ConfigurationManager.AppSettings["consumerKey"];
                tokens.ConsumerSecret = (string)ConfigurationManager.AppSettings["consumerSecret"];
                tokens.AccessToken = (string)ConfigurationManager.AppSettings["accessToken"];
                tokens.AccessTokenSecret = (string)ConfigurationManager.AppSettings["accessTokenSecret"];

                UserTimelineOptions userOptions = new UserTimelineOptions();
                userOptions.APIBaseAddress = (string)ConfigurationManager.AppSettings["APIBaseAddress"]; // <-- needed for API 1.1
                userOptions.Count = Convert.ToInt32(ConfigurationManager.AppSettings["TweetsToFetch"]);
                userOptions.UseSSL = Convert.ToBoolean(ConfigurationManager.AppSettings["UseSSL"]); // <-- needed for API 1.1
                userOptions.ScreenName = Convert.ToString(ConfigurationManager.AppSettings["ScreenName"]); ;//<-- replace with yours
                TwitterResponse<TwitterStatusCollection> timeline = TwitterTimeline.HomeTimeline(tokens, userOptions);

                StreamWriter objStreamWriter;
                objStreamWriter = new StreamWriter("c:\\logfile.txt");
                objStreamWriter.WriteLine("Content: " + timeline.Content + Environment.NewLine);
                objStreamWriter.WriteLine("Error Message: " + timeline.ErrorMessage + Environment.NewLine);
                objStreamWriter.WriteLine("Request URL: " + timeline.RequestUrl + Environment.NewLine);
                objStreamWriter.WriteLine("Response Object: " + timeline.ResponseObject + Environment.NewLine);
                objStreamWriter.WriteLine("Result: " + timeline.Result + Environment.NewLine);
                objStreamWriter.Close();

                return Json(timeline.Content, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                StreamWriter objStreamWriter;
                objStreamWriter = new StreamWriter("c:\\logfile_error.txt");
                objStreamWriter.WriteLine(ex.Message);
                objStreamWriter.Close();
                return new JsonResult();
            }
        }        

Can anybody guide me as to what might be going wrong ?

Thanks in advance