2013-06-04 44 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