2010-06-15 50 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增加,它就开始工作。