2013-06-04 50 views
0

我最近開始部署我的全功能的Twitter機器人(應該每天都會發佈一個新的短故事)到我的Twitter個人資料。它通過CRON在Azure上的工作被調用,並且被託管在MVC 4項目中。來自Azure的TweetSharp?

然而,當我嘗試在Azure上運行它(請記住,它工作正常本地),我收到以下錯誤:

[NetworkInformationException (0x5): Access is denied] 
    System.Net.NetworkInformation.SystemIPGlobalProperties.GetFixedInfo() +9059627 
    System.Net.NetworkInformation.SystemIPGlobalProperties.get_FixedInfo() +172 
    System.Net.NetworkInformation.SystemIPGlobalProperties.get_DomainName() +269 
    System.Net.CookieContainer..ctor() +121 
    Hammock.Web.WebQuery.AppendCookies(HttpWebRequest request) +242 
    Hammock.Web.WebQuery.SetRequestMeta(HttpWebRequest request) +147 
    Hammock.Web.WebQuery.HandleRequestMeta(WebRequest request) +146 
    Hammock.Web.WebQuery.BuildPostOrPutFormWebRequest(PostOrPut method, String url, Byte[]& content) +680 
    Hammock.Web.WebQuery.BuildPostOrPutWebRequest(PostOrPut method, String url, Byte[]& content) +168 
    Hammock.Web.WebQuery.ExecutePostOrPut(PostOrPut method, String url, WebException& exception) +181 
    Hammock.Web.WebQuery.Request(String url, WebException& exception) +252 
    Hammock.Authentication.OAuth.OAuthWebQuery.Request(String url, WebException& exception) +157 
    Hammock.RestClient.RequestImpl(RestRequest request) +943 
    Hammock.RestClient.Request(RestRequest request) +74 
    TweetSharp.TwitterService.WithHammockImpl(RestRequest request) +83 
    TweetSharp.TwitterService.WithHammock(WebMethod method, String path) +120 
    TweetSharp.TwitterService.SendTweet(SendTweetOptions options) +782 

我想這是因爲它使用了Azure不端口支持或類似的東西。或者是?我不知道從哪裏開始解決這個問題,並且當我搜索它時,在網絡上找不到任何幫助。

這是我的代碼。正如你所看到的,訪問令牌和祕密是硬編碼的,他們(就像我說的)本地工作:

var service = new TwitterService("qwdwqdqwd", "qwdwqdqwdqwd"); 
service.AuthenticateWith("qwdqwdqwdqwd", "qwdqwdqwdwqd"); 

var status = "Collaborative short story of the day: Blah"; 
var response = service.SendTweet(new SendTweetOptions() {Status = status}); //crash! 

問題是什麼?

回答

0

問題修正了它本身。我讓這個網站運行了幾個星期,突然之間,我注意到了來自該帳戶的推文。 CRON工作每天都在運行,並且有很多錯誤500消息,但是突然間(沒有觸及代碼),它工作。

Azure團隊必須對其進行一些內部更改。

1

您是否在Azure Web SiteAzure Cloud Service運行您的項目?

鑑於StackTrace,並且圍繞它進行挖掘,看起來SystemIPGlobalProperties使用了一些不安全的方法。 Using unsafe methods requires full trust

Caution Code written using an unsafe context cannot be verified to be safe, so it will be executed only when the code is fully trusted. In other words, unsafe code cannot be executed in an untrusted environment

此外,對系統組件的低級別訪問可能需要提升權限。 Windows Azure網站不支持完全信任,所以您不能在Azure網站中運行此代碼。

如果您運行Cloud Service,make sure that your code runs in Full Trust。如果這有幫助,那麼run your code with elevated privileges。 (runtime元素在您的csdef文件中)


+0

這確實是一個Azure網站。那麼除非我爲它提供服務,否則我沒有希望? –

+0

嘗試使用雲服務 - 如果它在那裏工作,我恐怕Hammock應該改變他們執行Web請求的方式,或者您必須在您有更多的環境控制權的地方使用Cloud Service。 – astaykov