代码之家  ›  专栏  ›  技术社区  ›  Koran

GWT查询第二次失败-仅

  •  0
  • Koran  · 技术社区  · 15 年前

    你好,

    我在GWT中有一个可视化功能,它调用同一面板的两个实例——两个查询。现在,假设一个URL是 另一个网址是 . 在这里,我面临一个问题,如果 先叫,然后两个都叫 作品。如果 先叫,然后才叫 作品, 超时。如果我两次都打电话 只有第一次 有效,第二次超时。如果我打电话 两次,两次都能正常工作。

    即使错误是在超时时出现的,但实际上它不是超时-在FF状态栏中,它显示直到-传输数据 然后它就卡住了。这甚至不会在第一次查询中出现。

    唯一的区别是 那是 返回非常快,而 返回的速度相对较慢。

    示例代码如下:

    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);
     }
    

    为什么会这样?我想不出为什么会这样?为什么这只是为了 而不是为了 ?

    编辑:更多研究。

    一直有效的查询(即 是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
    

    其中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.
    

    另外,请注意,应用引擎不允许Expires头段通过-这是原因吗?但如果这是原因,那么如果 先发再发 .

    评论〔1〕: http://spreadsheets.google.com/tq?key=pWiorx-0l9mwIuwX5CbEALA&range=A1:B12&gid=0&headers=-1

    1 回复  |  直到 15 年前
        1
  •  0
  •   Koran    15 年前

    这个问题解决了。这个错误的原因是google query response函数期望在同一个会话中的每个查询的响应reqid都会增加——我在任何地方都没有看到记录。一旦reqid增加,它就开始完美地工作。