2010-06-15 117 views
0

嗨,GWT查詢第二次失敗 - 僅

我在GWT中有一個可視化函數,它調用相同面板的兩個實例 - 兩個查詢。現在,假設一個網址是A而另一個網址是B。在這裏,我面臨的一個問題是,如果A首先被調用,那麼AB的作品。如果B被稱爲第一個,那麼只有B工程,A - 超時。如果我同時撥打A,只有第一次A有效,第二次超時。如果我撥打B兩次,它兩次都可以順利進行。

即使錯誤發生時,它實際上不會超時 - 在FF狀態欄,它顯示直到 - 從A傳輸數據,然後它卡住了。這甚至不會在第一次查詢時顯示出來。

之間的唯一區別是,回報非常快,而返回comparitively慢。

public Panel(){ 
    Runnable onLoadCallback = new Runnable() { 
     public void run() { 
      Query query = Query.create(dataUrl); 
      query.setTimeout(60); 
      query.send(new Callback() { 
      public void onResponse(QueryResponse response) { 
        if (response.isError()){ 
         Window.alert(response.getMessage()); 
        } 
       } 
      } 
     } 
     VisualizationUtils.loadVisualizationApi(onLoadCallback, PieChart.PACKAGE); 
} 

什麼能這樣做的原因:

示例代碼如下?我想不出爲什麼會發生這種情況?爲什麼這隻發生在A而不是B

編輯:更多研究。

所有時間都有效的查詢(即B是GWT可視化站點中給出的示例URL:請參見comment [1])。所以,我在我的應用程序引擎試圖重現 - 以下方式

s = "google.visualization.Query.setResponse({version:'0.6',status:'ok',sig:'106459472',table:{cols:[{id:'A',label:'Source',type:'string',pattern:''},{id:'B',label:'Percent',type:'number',pattern:'#0.01%'}],rows:[{c:[{v:'Oil'},{v:0.37,f:'37.00%'}]},{c:[{v:'Coal'},{v:0.25,f:'25.00%'}]},{c:[{v:'Natural Gas'},{v:0.23,f:'23.00%'}]},{c:[{v:'Nuclear'},{v:0.06,f:'6.00%'}]},{c:[{v:'Biomass'},{v:0.04,f:'4.00%'}]},{c:[{v:'Hydro'},{v:0.03,f:'3.00%'}]},{c:[{v:'Solar Heat'},{v:0.005,f:'0.50%'}]},{c:[{v:'Wind'},{v:0.003,f:'0.30%'}]},{c:[{v:'Geothermal'},{v:0.002,f:'0.20%'}]},{c:[{v:'Biofuels'},{v:0.002,f:'0.20%'}]},{c:[{v:'Solar photovoltaic'},{v:4.0E-4,f:'0.04%'}]}]}});"; 
    response = HttpResponse(s, content_type="text/plain; charset=utf-8") 
    response['Expires'] = time.strftime('%a, %d %b %Y %H:%M:%S GMT', time.gmtime()) 
    return response 

其中S爲數據,當我們運行查詢。我試圖添加Expires等,因爲這似乎是唯一的區別,但現在,查詢一直失敗。

欲瞭解更多信息 - 我現在發送我的服務器響應與工作服務器響應之間的差異。他們似乎很相似。

HTTP/1.0 200 OK 
Content-Type: text/plain 
Date: Wed, 16 Jun 2010 11:07:12 GMT 
Server: Google Frontend 
Cache-Control: private, x-gzip-ok="" 

google.visualization.Query.setResponse({version:'0.6',status:'ok',sig:'106459472',table:{cols:[{id:'A',label:'Source',type:'string',pattern:''},{id:'B',label:'Percent',type:'number',pattern:'#0.01%'}],rows:[{c:[{v:'Oil'},{v:0.37,f:'37.00%'}]},{c:[{v:'Coal'},{v:0.25,f:'25.00%'}]},{c:[{v:'Natural Gas'},{v:0.23,f:'23.00%'}]},{c:[{v:'Nuclear'},{v:0.06,f:'6.00%'}]},{c:[{v:'Biomass'},{v:0.04,f:'4.00%'}]},{c:[{v:'Hydro'},{v:0.03,f:'3.00%'}]},{c:[{v:'Solar Heat'},{v:0.005,f:'0.50%'}]},{c:[{v:'Wind'},{v:0.003,f:'0.30%'}]},{c:[{v:'Geothermal'},{v:0.002,f:'0.20%'}]},{c:[{v:'Biofuels'},{v:0.002,f:'0.20%'}]},{c:[{v:'Solar photovoltaic'},{v:4.0E-4,f:'0.04%'}]}]}});Connection closed by foreign host. 


Mac$ telnet spreadsheets.google.com 80 
Trying 209.85.231.100... 
Connected to spreadsheets.l.google.com. 
Escape character is '^]'. 
GET http://spreadsheets.google.com/tq?key=pWiorx-0l9mwIuwX5CbEALA&range=A1:B12&gid=0&headers=-1 
HTTP/1.0 200 OK 
Content-Type: text/plain; charset=UTF-8 
Date: Wed, 16 Jun 2010 11:07:58 GMT 
Expires: Wed, 16 Jun 2010 11:07:58 GMT 
Cache-Control: private, max-age=0 
X-Content-Type-Options: nosniff 
X-XSS-Protection: 1; mode=block 
Server: GSE 

google.visualization.Query.setResponse({version:'0.6',status:'ok',sig:'106459472',table:{cols:[{id:'A',label:'Source',type:'string',pattern:''},{id:'B',label:'Percent',type:'number',pattern:'#0.01%'}],rows:[{c:[{v:'Oil'},{v:0.37,f:'37.00%'}]},{c:[{v:'Coal'},{v:0.25,f:'25.00%'}]},{c:[{v:'Natural Gas'},{v:0.23,f:'23.00%'}]},{c:[{v:'Nuclear'},{v:0.06,f:'6.00%'}]},{c:[{v:'Biomass'},{v:0.04,f:'4.00%'}]},{c:[{v:'Hydro'},{v:0.03,f:'3.00%'}]},{c:[{v:'Solar Heat'},{v:0.005,f:'0.50%'}]},{c:[{v:'Wind'},{v:0.003,f:'0.30%'}]},{c:[{v:'Geothermal'},{v:0.002,f:'0.20%'}]},{c:[{v:'Biofuels'},{v:0.002,f:'0.20%'}]},{c:[{v:'Solar photovoltaic'},{v:4.0E-4,f:'0.04%'}]}]}});Connection closed by foreign host. 

此外,請注意,應用程序引擎不允許過期頭部通過 - 這可能是原因嗎?但如果這是原因,那麼它應該不會失敗,如果B先發送然後A

評論[1]:http://spreadsheets.google.com/tq?key=pWiorx-0l9mwIuwX5CbEALA&range=A1:B12&gid=0&headers=-1

回答

0

這個問題就解決了。這個錯誤的原因是谷歌QueryResponse函數期望響應reqId增加在同一個會話中的每個查詢 - 我沒有看到任何地方記錄。一旦reqId增加,它就開始工作。