google / google-visualization-issues

288 stars 35 forks source link

Json response within 1 sec but still get timeout after 30 sec and no "pause on exception" #1240

Open orwant opened 9 years ago

orwant commented 9 years ago
Json response within 1 sec but still get timeout after 30 sec and no "pause on exception"

Hi, I've tested this code in various constellations and only one of the constellations
is giving me an error that I can't track down yet. Maybe someone else with more google-visualization
experience can see the problem. In this one case, get the json resonse, then I get
a token error with no token identified in the error message and "paus on error" does
not pause anywhere in my js nor in external js. Then, after 30 sec. my callback is
indeed called but with the error set to timeout (error in query).

Here is the URL which you can also test without SSL
====================================================

https://cio-services.eu/demoOe2/Api/Insight/GetESiteEuoChart/?viewFlag=1&eSiteKid=4b92d450-b29d-47c0-943b-00890f56caf2&periodMin=7200&keyProp=KW15&tqx=reqId%3A0

Here is my client js which works in several scenarios
======================================================

    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">

        var chartOptions = {
            curveType: 'none',
            //width: 1200,
            height: 400, 
            vAxis: { maxValue: 10, title: 'kWh/4 (15 min)' },
            hAxis: { title: 'Time' },
            title: 'Live production log',
            titlePosition: 'out',
            titleTextStyle: { fontSize: 14, textIndent: 10 },
            fontSize: 12
        };

        google.load("visualization", "1", { packages: ["corechart"] });
        google.setOnLoadCallback(drawChart);
        var _chart;

        function drawChart() {

            //GET GChart data           
            var query = new google.visualization.Query('https://cio-services.eu:9995/Insight/GetESiteEuoChart/?viewFlag=1&eSiteKid=4b92d450-b29d-47c0-943b-00890f56caf2&periodMin=720&keyProp=KW15');

            //set query parameters
            //query.setQuery('select 1, 2');

            query.send(drawTable);
        }

        function drawTable(response) {
            //error checking
            if (response.isError()) {
                alert('Error in query: ' + response.getMessage() + '' + response.getDetailedMessage());
                return;
            }

            //convert response to JSON string
            var googleDataQuery = response.getDataTable().toJSON();

            //Convert JSON to google Data table
            var convertedData = new google.visualization.DataTable(googleDataQuery,
0.5);

            //Initialize a specific data table sub set view and store into a variable

            var view = new google.visualization.DataView(convertedData);

            _chart.draw(view, chartOptions);
        }

        $(function () {     
            _chart = new google.visualization.LineChart(document.getElementById('chart_div'));
        });

    </script>

Original issue reported on code.google.com by testorhubert on 2013-06-21 09:08:21

orwant commented 9 years ago
edit: to test, the internal url in the script should  be the same as te external one
shown above: https://cio-services.eu/demoOe2/Api/Insight/GetESiteEuoChart/?viewFlag=1&eSiteKid=4b92d450-b29d-47c0-943b-00890f56caf2&periodMin=7200&keyProp=KW15&tqx=reqId%3A0

Original issue reported on code.google.com by testorhubert on 2013-06-21 09:44:11

orwant commented 9 years ago
JSFiddle: http://jsfiddle.net/GGleGrand/44SD9/

Fiddler: 217 No Connection: close, no Content-Length. No way to tell if the response
is complete.
I'm suspecting that I'm somehow not closing my ASP.Net WebApi response but I'm not
sure why it isn't closed and also not sure why it works in other cases...

Original issue reported on code.google.com by testorhubert on 2013-06-21 13:05:50

orwant commented 9 years ago
Connection is being closed properly so that wasn't it :-( Same error in chrome, firefox,
ie10 whereby ie10 tells me SCRIPT1004: Expected ';' GetESiteEuoChart, line 1 character
11. What? 

Original issue reported on code.google.com by testorhubert on 2013-06-21 13:29:28

orwant commented 9 years ago
Json content being returned:
{"version":"0.6","reqId":"0","status":"ok","sig":"5982206968295329967","table":{"cols":[{"id":"xaxis","label":"kWh15","type":"string"},{"id":"1","label":"BHKW
Senertec 081664bf80eb-8173-239f-faf5-24510b160130","type":"number"},{"id":"2","label":"eStorage
Varta 471240ef542a-6fdf-19c3-9453-4b3bba9e5a65","type":"number"}],"rows":[{"c":[{"v":"21:36","f":"One"},{"v":"3","f":"One"},{"v":"1","f":"One"}]},{"c":[{"v":"21:51","f":"One"},{"v":"2","f":"One"},{"v":"4","f":"One"}]},{"c":[{"v":"22:06","f":"One"},{"v":"3","f":"One"},{"v":"3","f":"One"}]},{"c":[{"v":"22:21","f":"One"},{"v":"8","f":"One"},{"v":"5","f":"One"}]},{"c":[{"v":"22:36","f":"One"},{"v":"0","f":"One"},{"v":"0","f":"One"}]},{"c":[{"v":"22:51","f":"One"},{"v":"0","f":"One"},{"v":"6","f":"One"}]},{"c":[{"v":"23:06","f":"One"},{"v":"0","f":"One"},{"v":"0","f":"One"}]},{"c":[{"v":"23:21","f":"One"},{"v":"0","f":"One"},{"v":"0","f":"One"}]},{"c":[{"v":"23:36","f":"One"},{"v":"1","f":"One"},{"v":"1","f":"One"}]},{"c":[{"v":"23:51","f":"One"},{"v":"1","f":"One"},{"v":"3","f":"One"}]},{"c":[{"v":"0:06","f":"One"},{"v":"5","f":"One"},{"v":"5","f":"One"}]},{"c":[{"v":"0:21","f":"One"},{"v":"4","f":"One"},{"v":"7","f":"One"}]},{"c":[{"v":"0:37","f":"One"},{"v":"6","f":"One"},{"v":"6","f":"One"}]},{"c":[{"v":"0:52","f":"One"},{"v":"0","f":"One"},{"v":"5","f":"One"}]},{"c":[{"v":"1:07","f":"One"},{"v":"1","f":"One"},{"v":"0","f":"One"}]},{"c":[{"v":"1:22","f":"One"},{"v":"8","f":"One"},{"v":"1","f":"One"}]},{"c":[{"v":"1:37","f":"One"},{"v":"8","f":"One"},{"v":"7","f":"One"}]},{"c":[{"v":"1:52","f":"One"},{"v":"3","f":"One"},{"v":"7","f":"One"}]},{"c":[{"v":"2:07","f":"One"},{"v":"8","f":"One"},{"v":"8","f":"One"}]},{"c":[{"v":"2:22","f":"One"},{"v":"2","f":"One"},{"v":"6","f":"One"}]},{"c":[{"v":"2:37","f":"One"},{"v":"3","f":"One"},{"v":"6","f":"One"}]},{"c":[{"v":"2:52","f":"One"},{"v":"1","f":"One"},{"v":"1","f":"One"}]},{"c":[{"v":"3:07","f":"One"},{"v":"6","f":"One"},{"v":"6","f":"One"}]},{"c":[{"v":"3:22","f":"One"},{"v":"6","f":"One"},{"v":"4","f":"One"}]},{"c":[{"v":"3:37","f":"One"},{"v":"9","f":"One"},{"v":"9","f":"One"}]},{"c":[{"v":"3:52","f":"One"},{"v":"8","f":"One"},{"v":"8","f":"One"}]},{"c":[{"v":"4:07","f":"One"},{"v":"8","f":"One"},{"v":"6","f":"One"}]},{"c":[{"v":"4:22","f":"One"},{"v":"0","f":"One"},{"v":"0","f":"One"}]},{"c":[{"v":"4:37","f":"One"},{"v":"0","f":"One"},{"v":"0","f":"One"}]},{"c":[{"v":"4:52","f":"One"},{"v":"6","f":"One"},{"v":"5","f":"One"}]},{"c":[{"v":"5:07","f":"One"},{"v":"8","f":"One"},{"v":"8","f":"One"}]},{"c":[{"v":"5:22","f":"One"},{"v":"4","f":"One"},{"v":"4","f":"One"}]},{"c":[{"v":"5:37","f":"One"},{"v":"9","f":"One"},{"v":"5","f":"One"}]},{"c":[{"v":"5:53","f":"One"},{"v":"1","f":"One"},{"v":"4","f":"One"}]},{"c":[{"v":"6:08","f":"One"},{"v":"6","f":"One"},{"v":"7","f":"One"}]},{"c":[{"v":"6:23","f":"One"},{"v":"5","f":"One"},{"v":"4","f":"One"}]},{"c":[{"v":"6:38","f":"One"},{"v":"2","f":"One"},{"v":"2","f":"One"}]},{"c":[{"v":"6:53","f":"One"},{"v":"4","f":"One"},{"v":"8","f":"One"}]},{"c":[{"v":"7:08","f":"One"},{"v":"3","f":"One"},{"v":"3","f":"One"}]},{"c":[{"v":"7:23","f":"One"},{"v":"6","f":"One"},{"v":"4","f":"One"}]},{"c":[{"v":"7:38","f":"One"},{"v":"3","f":"One"},{"v":"5","f":"One"}]},{"c":[{"v":"7:53","f":"One"},{"v":"9","f":"One"},{"v":"9","f":"One"}]}],"p":{}}}

Original issue reported on code.google.com by testorhubert on 2013-06-21 13:30:05

orwant commented 9 years ago
Does google-visualization perhaps have a problem with legit use of CORS ... which I
am using here. I still can't nail down the exception in the js debugger.

Original issue reported on code.google.com by testorhubert on 2013-06-21 13:34:00

orwant commented 9 years ago
Request URL:https://cio-services.eu/demoOe2/Api/Insight/GetESiteEuoChart/?viewFlag=1&eSiteKid=4b92d450-b29d-47c0-943b-00890f56caf2&periodMin=7200&keyProp=KW15&tq=select%201%2C%202&tqx=reqId%3A0
Request Method:GET
Status Code:200 OK
Request Headersview source
Accept:*/*
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8,de-DE;q=0.6,de;q=0.4
Connection:keep-alive
Cookie:.ASPXBrowserOverride=Mozilla%2f5.0+(iPhone%3b+U%3b+CPU+iPhone+OS+4_3_3+like+Mac+OS+X%3b+en-us)+AppleWebKit%2f533.17.9+(KHTML%2c+like+Gecko)+Version%2f5.0.2+Mobile%2f8J2+Safari%2f6533.18.5
Host:cio-services.eu
Referer:https://www.optener.com/Insight
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/27.0.1453.116 Safari/537.36
Query String Parametersview sourceview URL encoded
viewFlag:1
eSiteKid:4b92d450-b29d-47c0-943b-00890f56caf2
periodMin:7200
keyProp:KW15
tq:select 1, 2
tqx:reqId:0
Response Headersview source
Cache-Control:no-cache
Content-Length:3330
Content-Type:application/json; charset=utf-8
Date:Fri, 21 Jun 2013 14:05:57 GMT
Expires:-1
Pragma:no-cache
Server:Microsoft-IIS/7.5
X-AspNet-Version:4.0.30319
X-Powered-By:ASP.NET

Original issue reported on code.google.com by testorhubert on 2013-06-21 14:04:01

orwant commented 9 years ago
Using code I got from your fiddle reference, and fixing some problems that version had
(now in http://jsfiddle.net/dlaliberte/hw6h2/)  I am seeing a syntax error in the JSON
reported in the console for both Chrome and Firefox.  FF provides more info.

SyntaxError: invalid label

{"version":"0.6","reqId":"0","status":"ok","sig":"59822069682

?viewF...reqId:0 (line 1, col 1)

(There should be a pointer at the first double quote of "version" .)

This error seems to happen for a lot of people when using JSONP incorrectly, but it
does not appear you are using JSONP.  A non-JSONP question (at http://lesseverything.com/blog/archives/2007/10/25/invalid-label-error-when-eval-json/)
has an answer that suggests there is a need for extra '(' ... ')' wrapping around the
JSON.  Maybe the service you are using doesn't include the parens around the response,
so the evaluator would have to do that instead.

After 30 seconds, I am also seeing the timeout that you see, but this syntax error
is probably the culprit.  Hope that helps.

Original issue reported on code.google.com by dlaliberte@google.com on 2013-06-21 14:14:53

orwant commented 9 years ago
Issue 1239 has been merged into this issue.

Original issue reported on code.google.com by dlaliberte@google.com on 2013-06-21 14:15:32

orwant commented 9 years ago
A better explanation of the cause of the "invalid label" error is at: 

  http://willcode4beer.com/tips.jsp?set=jsonInvalidLabel

which says: "The problem occurs because eval is interpreting the first item in the
JSON string as a JavaScript Label. The solution is to wrap the JSON string in parenthesis."

Original issue reported on code.google.com by dlaliberte@google.com on 2013-06-21 14:17:41

orwant commented 9 years ago
Still same problem :-( after changing the return format and now looks like: 
"({\"version\":\"0.6\",\"reqId\":\"0\",\"status\":\"...)"
And all my console errors are gone: no exceptions, no errors, still the timeout error.

Wait! Why is my tqx=reqId%3A0 always zero here? On my local test machine it is always
non zero. Something is awry. Any ideas?

Reproducible at: http://jsfiddle.net/GGleGrand/44SD9/

Original issue reported on code.google.com by testorhubert on 2013-06-21 17:26:08

orwant commented 9 years ago
where is the debug (non compressed) version of the google jsapi library?

Original issue reported on code.google.com by testorhubert on 2013-06-21 21:53:45

orwant commented 9 years ago
The json format is not the problem, nor is the reqId probably. I suspect a CORS problem,
something to do with

X-DataSource-Auth: a
Referer: 

in the header. Looking into this now.

Original issue reported on code.google.com by testorhubert on 2013-06-22 13:20:31

orwant commented 9 years ago
OK, there is a bit of magic going on here that requires attentive reading of the doc
to understand.

https://developers.google.com/chart/interactive/docs/dev/implementing_data_source
JSON Response Format

The default response format is JSON if the request includes an "X-DataSource-Auth"
header, and JSONP otherwise. Note that the Google chart client actually supports a
modified version of JSON and JSONP; if you are using the Java or Python helper libraries,
they will put out the proper code for you; if you are parsing responses by hand, see
JSON Modifications below
---
What happens is:

if you supply a target domain that in any way differs (even a different port) from
the home domain, then google-visualization decides to remove the  "X-DataSource-Auth"
 header property and thereby triggers the client to expect jsonP instead of json. Apparently
the RequestID is also always zero in these cases. In any case, this means that you
cannot siply reuse APIs for CORS and non-CORS access.

R

Original issue reported on code.google.com by testorhubert on 2013-06-22 19:47:20

orwant commented 9 years ago
How can i get following format 

                      ['Month', 'TS', 'IS', 'AVPRO'],
                      ['A',   2,       1,           0.5],
                      ['B',   2,       0.5,         1],
                      ['C',   4,       1,           0.5],
                      ['D',   8,       0.5,         1],
                      ['E',   7,       1,           0.5],
                      ['F',   7,       0.5,         1],
                      ['G',   8,       1,           0.5],
                      ['H',   4,       0.5,         1],
                      ['I',   2,       1,           0.5],
                      ['J',   3.5,     0.5,         1],
                      ['K',   3,       1,           0.5],
                      ['L',   3.5,     0.5,         1],
                      ['M',   1,       1,           0.5],
                      ['N',   1,       0.5,         1] 

From following json Response : 

     [{"total":18,"data":[
        {"querydate":"1/27/2014","name1":23604,"name2":12418,"name3":1405,"name4":22433,"name5":593,"name6":20,"name7":13600,"name8":8},
        {"querydate":"1/28/2014","name1":23604,"name2":12418,"name3":1405,"name4":22433,"name5":593,"name6":20,"name7":13600,"name8":8},
        {"querydate":"1/29/2014","name1":23604,"name2":12418,"name3":1405,"name4":22433,"name5":593,"name6":19,"name7":13600,"name8":8},
        {"querydate":"1/1/2014","name1":23603,"name2":12418,"name3":1405,"name4":22433,"name5":593,"name6":19,"name7":13600,"name8":8},
        {"querydate":"1/2/2014","name1":23543,"name2":12392,"name3":1404,"name4":22405,"name5":593,"name6":19,"name7":13581,"name8":8},
        {"querydate":"1/3/2014","name1":19740,"name2":10235,"name3":1116,"name4":18878,"name5":477,"name6":19,"name7":11628,"name8":6},
        {"querydate":"1/4/2014","name1":22467,"name2":11855,"name3":1328,"name4":22520,"name5":506,"name6":16,"name7":13697,"name8":9},
        {"querydate":"1/5/2014","name1":22467,"name2":11855,"name3":1328,"name4":22520,"name5":506,"name6":16,"name7":13697,"name8":9},
        {"querydate":"1/6/2014","name1":22467,"name2":11855,"name3":1328,"name4":22520,"name5":506,"name6":16,"name7":13697,"name8":9},
        {"querydate":"1/7/2014","name1":22466,"name2":11855,"name3":1328,"name4":22518,"name5":506,"name6":16,"name7":13697,"name8":9},
        {"querydate":"1/8/2014","name1":19795,"name2":10394,"name3":1191,"name4":19738,"name5":462,"name6":16,"name7":11913,"name8":8},
        {"querydate":"1/9/2014","name1":21936,"name2":11101,"name3":1292,"name4":21526,"name5":460,"name6":19,"name7":13740,"name8":9},
        {"querydate":"1/10/2014","name1":21936,"name2":11101,"name3":1292,"name4":21526,"name5":460,"name6":19,"name7":13740,"name8":9},
        {"querydate":"1/11/2014","name1":21936,"name2":11101,"name3":1292,"name4":21526,"name5":460,"name6":19,"name7":13740,"name8":9},
        {"querydate":"1/11/2014","name1":21936,"name2":11101,"name3":1292,"name4":21526,"name5":460,"name6":19,"name7":13740,"name8":9},
        {"querydate":"1/12/2014","name1":21935,"name2":11100,"name3":1292,"name4":21523,"name5":460,"name6":19,"name7":13737,"name8":9},
        {"querydate":"1/14/2014","name1":21775,"name2":10998,"name3":1290,"name4":21424,"name5":457,"name6":19,"name7":13688,"name8":9},
        {"querydate":"1/15/2014","name1":21775,"name2":10998,"name3":1290,"name4":21424,"name5":457,"name6":19,"name7":13688,"name8":9}]}

please give me solution

i want result in  following format.

                      ['Month', 'TS', 'IS', 'AVPRO'],
                      ['A',   2,       1,           0.5],
                      ['B',   2,       0.5,         1],
                      ['C',   4,       1,           0.5],
                      ['D',   8,       0.5,         1],
                      ['E',   7,       1,           0.5],
                      ['F',   7,       0.5,         1],
                      ['G',   8,       1,           0.5],
                      ['H',   4,       0.5,         1],
                      ['I',   2,       1,           0.5],
                      ['J',   3.5,     0.5,         1],
                      ['K',   3,       1,           0.5],
                      ['L',   3.5,     0.5,         1],
                      ['M',   1,       1,           0.5],
                      ['N',   1,       0.5,         1] 

Please Help me out in this.

Original issue reported on code.google.com by omkar.thorat.30 on 2014-03-05 09:05:11