General

Reply
Accepted Solution

HttpRequest Time Out.....

[ Edited ]

Hello, When request CallBack it is error "System.Net.WebException: The operation has timed out."

:Shame:

 

AppMainUpdate

{

.....

 WClient.SendQuery();

.....

}

 

 

 

-----------------------------------------------

public static class WClient  {  

     private static Queue<UriPack> QueueList = new Queue<UriPack> ();  

 private static Dictionary<string,EventHandler> DicRequest =new Dictionary<string, EventHandler> ();   private static String TimeInfoUri = "http://www.xxx.com.cn/data/sk/{0}.html";

 private static String CurrentKey;

  private static Uri CurrentUri;  

 private static bool isNext = true;

 

 private static void AddRequest (Uri uriStr, EventHandler e)   {  

  string key = Guid.NewGuid ().ToString ();    

DicRequest.Add (key, e);

   lock (QueueList) {   

  QueueList.Enqueue (new UriPack (key, uriStr));

   }

  }   

public static void SendQuery ()   {  

     lock (QueueList) {     

     if (QueueList.Count > 0) {

     if (isNext) {  

     isNext = false;     

  SendQuerySpeed (QueueList.Dequeue());    

  } 

    }             

   }             

    }       

 public static void SendQuerySpeed (UriPack site)   {  

  CurrentKey = site.Key;  

  CurrentUri = site.UriStr;

   var request = HttpWebRequest.Create (CurrentUri);

   request.Timeout=10000;

   request.BeginGetResponse (new AsyncCallback (requestCallBack), request);

     }

       /// <summary>

  /// 处理下载事件

  /// </summary>   

/// <param name="sender"></param>   

/// <param name="args"></param>   

static   void  requestCallBack (IAsyncResult ar)   {        

string tempstr="";        

var webRequest = (HttpWebRequest)ar.AsyncState;

   using(var webResponse = (HttpWebResponse)webRequest.EndGetResponse (ar))    {

          using(var stream = webResponse.GetResponseStream())     {       

 using(var sr=new StreamReader(stream))     {     

 tempstr=sr.ReadToEnd();           // time out!!

 }  

   }   

    }       

 DicRequest [CurrentKey] (tempstr, null);    

DicRequest.Remove (CurrentKey);      

  isNext = true;    

   }           

 }

Please use plain text.

Re: HttpRequest Time Out.....

I find the reason, only the first request this error, request willsucceed next time

Please use plain text.
Announcements

Welcome to the PlayStation Mobile Developer Forums


This is a community for the discussion of technical topics with other developers and SCE engineers. Posting ideas/requests are also appreciated. Join the discussion!

PlayStation®Mobile開発者フォーラムでは世界中の開発者の皆様と一緒に、議論や情報交換が可能です。SCEも議論に参加し、皆様の開発をサポートします。アイデアやリクエストも大歓迎です。ぜひご参加ください。

PSM Developer Registration (for free) on PSM DevPortal is required to post on the forum.
Please sign out then sign in again to the forum and PSM DevPortal after you have completed the registration.

フォーラムへ投稿をするにはPSM DevPortalへの登録(無料)が必要です。
登録後はフォーラムと PSM DevPortalを一度ログアウトし、再度ログインしてください。