HI,
我在GWT中有一个可视化功能,它可以调用两个相同面板的实例 - 两个查询。现在,假设一个网址是 A ,另一个网址是 B 。在这里,我遇到一个问题,如果首先调用 A ,那么 A 和 B 都可以工作。如果首先调用 B ,则只有 B 有效, A - 超时。如果我同时拨打 A ,则只有第一次 A 工作,第二次超时。如果我两次打电话给 B ,它可以顺利地工作两次。
即使错误在超时时出现,它实际上也没有超时 - 在FF状态栏中,它显示直到 - 从 A 传输数据,然后它被卡住了。这甚至不会出现在第一次查询中。
A 和 B 之间的唯一区别是 B 返回的速度非常快,而 A 返回速度相对较慢
示例代码如下:
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:请参阅注释[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
当我们运行 B 的查询时,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.
另外,请注意App引擎不允许Expires标头通过 - 这可能是原因吗?但如果这是原因,那么如果首先发送 B 然后 A ,它就不会失败。
评论[1]:http://spreadsheets.google.com/tq?key=pWiorx-0l9mwIuwX5CbEALA&range=A1:B12&gid=0&headers=-1
答案 0 :(得分:0)
此问题已解决。出现此错误的原因是google QueryResponse函数希望响应reqId在同一会话中针对每个查询递增 - 我在任何地方都没有看到。一旦reqId递增,它就会开始完美地运作。