Querying with HistorianProvider implementation

ignition79
#1

I have the following method overridden after I extend ‘HistorianProvider’ and implements ‘Historian’

@Override
	public QueryResult query(List<String> tags, long startTime, long endTime, boolean bounding) {
		List<PathInfo> pathInfos = new ArrayList<>();
		BasicQueryResult queryResult = new BasicQueryResult(pathInfos);
		for (String tag : tags) {
			log.info("the tag path: " + tag);
			BasicPathInfo basicPathInfo = new BasicPathInfo(0, "[default]aquarium/flowmeter", DataType.Int4);
			pathInfos.add(basicPathInfo);
			BasicResultDataPoint dataPoint = new BasicResultDataPoint(0, "[default]aquarium/flowmeter", 333, 1, 1560534743);
			queryResult.publish(dataPoint);
		}

		queryResult.finish();
		return queryResult;
	}

When I open the tag within the EasyChart, I get a Gateway read timeout error as follows:

java.lang.Exception: Error running query:
TagHistory(paths=[histprov:testing:/drv:ignitiondemo:default:/tag:aquarium/flowmeter], start=Fri Jun 14 12:39:00 MDT 2019, end=Fri Jun 14 12:49:59 MDT 2019, flags=0)@0ms
On: Main Window.Root Container.Easy Chart
	at com.inductiveautomation.factorypmi.application.gateway.QueryManager$QueryExecutor.run(QueryManager.java:308)
	at java.lang.Thread.run(Unknown Source)
Caused by: com.inductiveautomation.ignition.client.gateway_interface.GatewayException: Read timed out
	at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.newGatewayException(GatewayInterface.java:341)
	at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.getResponse(GatewayInterface.java:501)
	at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.sendMessage(GatewayInterface.java:273)
	at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.runTagHistoryQuery(GatewayInterface.java:726)
	at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.runTagHistoryQuery(GatewayInterface.java:694)
	at com.inductiveautomation.factorypmi.application.gateway.GwiTagHistoryProvider.query(GwiTagHistoryProvider.java:16)
	at com.inductiveautomation.ignition.common.sqltags.history.cache.StandardCacheBucket.loadData(StandardCacheBucket.java:233)
	at com.inductiveautomation.ignition.common.sqltags.history.cache.StandardCacheBucket.getData(StandardCacheBucket.java:193)
	at com.inductiveautomation.ignition.common.sqltags.history.cache.SubCache$BucketHit.getData(SubCache.java:217)
	at com.inductiveautomation.ignition.common.sqltags.history.cache.SubCache.getData(SubCache.java:159)
	at com.inductiveautomation.ignition.common.sqltags.history.cache.TagHistoryCache.query(TagHistoryCache.java:254)
	at com.inductiveautomation.factorypmi.application.gateway.TagHistoryQuery.execute(TagHistoryQuery.java:34)
	at com.inductiveautomation.factorypmi.application.gateway.QueryManager$Query.execute(QueryManager.java:657)
	at com.inductiveautomation.factorypmi.application.gateway.QueryManager$Query.access$500(QueryManager.java:630)
	at com.inductiveautomation.factorypmi.application.gateway.QueryManager$QueryExecutor.run(QueryManager.java:306)
	... 1 more
Caused by: java.net.SocketTimeoutException: Read timed out
	at java.net.SocketInputStream.socketRead0(Native Method)
	at java.net.SocketInputStream.socketRead(Unknown Source)
	at java.net.SocketInputStream.read(Unknown Source)
	at java.net.SocketInputStream.read(Unknown Source)
	at java.io.BufferedInputStream.fill(Unknown Source)
	at java.io.BufferedInputStream.read1(Unknown Source)
	at java.io.BufferedInputStream.read(Unknown Source)
	at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)
	at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
	at java.net.HttpURLConnection.getResponseCode(Unknown Source)
	at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.getResponse(GatewayInterface.java:421)
	... 14 more

Ignition v7.9.10 (b2018112821)
Java: Oracle Corporation 1.8.0_211

What am I missing in the code for this to work properly?

0 Likes

#2

I would start by putting the Tags.History loggers on the gateway to DEBUG or TRACE level - it might be that you’re not implementing a needed API method (though it seems like subclassing HistorianProvider should be enough)

0 Likes

#3

Can you please provide a bit more details on how to do this?

0 Likes

#4

See this KBA: https://support.inductiveautomation.com/index.php?/Knowledgebase/Article/View/119/0/obtaining-ignition-logs#change-logger-level

For the search query, just enter ‘History’ - there should be quite a few loggers named something like ‘Tags.Query.History’ and related names.

0 Likes

#5

Okay, I have turned it on Debug as follows:

The wrapper.log shows the following:

INFO   | jvm 1    | 2019/06/14 14:14:01 | D [T.H.Query                     ] [20:14:01]: (id=431110f3) Starting history query for 1 tag(s). Parameters: [2019-06-14 12:39:00.0 -> 2019-06-14 12:49:59.999, 301 points, 'MinMax', 'Wide'] Tags: [[histprov:testing:/drv:ignitiondemo:default:/tag:aquarium/flowmeter]] Aliases: [null] Aggregation Mode Overrides: [null] Flags: [NONE] request-origin=127.0.0.1, session-user=admin, session-project=IgnitionDemo, session-id=AFE02FF2, queryid=431110f3
INFO   | jvm 1    | 2019/06/14 14:14:01 | D [T.H.Query                     ] [20:14:01]: (id=431110f3) Broke input columns into 1 subsets. Keys=[{histprov/testing}] request-origin=127.0.0.1, session-user=admin, session-project=IgnitionDemo, session-id=AFE02FF2, queryid=431110f3
INFO   | jvm 1    | 2019/06/14 14:14:01 | D [T.H.Q.ResultWriter            ] [20:14:01]: (id=431110f3) Using block window size of 2 seconds [2193 ms]. request-origin=127.0.0.1, session-user=admin, session-project=IgnitionDemo, session-id=AFE02FF2, queryid=431110f3
INFO   | jvm 1    | 2019/06/14 14:14:01 | Jun 14, 2019 2:14:01 PM com.shookiot.IgnitionConnector.HistoryProvider query
INFO   | jvm 1    | 2019/06/14 14:14:01 | INFO: the tag path: [default]aquarium/flowmeter

with the same error in the Designer:

java.lang.Exception: Error running query:
TagHistory(paths=[histprov:testing:/drv:ignitiondemo:default:/tag:aquarium/flowmeter], start=Fri Jun 14 12:39:00 MDT 2019, end=Fri Jun 14 12:49:59 MDT 2019, flags=0)@0ms
On: Main Window.Root Container.Easy Chart
	at com.inductiveautomation.factorypmi.application.gateway.QueryManager$QueryExecutor.run(QueryManager.java:308)
	at java.lang.Thread.run(Unknown Source)
Caused by: com.inductiveautomation.ignition.client.gateway_interface.GatewayException: Read timed out
	at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.newGatewayException(GatewayInterface.java:341)
	at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.getResponse(GatewayInterface.java:501)
	at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.sendMessage(GatewayInterface.java:273)
	at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.runTagHistoryQuery(GatewayInterface.java:726)
	at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.runTagHistoryQuery(GatewayInterface.java:694)
	at com.inductiveautomation.factorypmi.application.gateway.GwiTagHistoryProvider.query(GwiTagHistoryProvider.java:16)
	at com.inductiveautomation.ignition.common.sqltags.history.cache.StandardCacheBucket.loadData(StandardCacheBucket.java:233)
	at com.inductiveautomation.ignition.common.sqltags.history.cache.StandardCacheBucket.getData(StandardCacheBucket.java:193)
	at com.inductiveautomation.ignition.common.sqltags.history.cache.SubCache$BucketHit.getData(SubCache.java:217)
	at com.inductiveautomation.ignition.common.sqltags.history.cache.SubCache.getData(SubCache.java:159)
	at com.inductiveautomation.ignition.common.sqltags.history.cache.TagHistoryCache.query(TagHistoryCache.java:254)
	at com.inductiveautomation.factorypmi.application.gateway.TagHistoryQuery.execute(TagHistoryQuery.java:34)
	at com.inductiveautomation.factorypmi.application.gateway.QueryManager$Query.execute(QueryManager.java:657)
	at com.inductiveautomation.factorypmi.application.gateway.QueryManager$Query.access$500(QueryManager.java:630)
	at com.inductiveautomation.factorypmi.application.gateway.QueryManager$QueryExecutor.run(QueryManager.java:306)
	... 1 more
Caused by: java.net.SocketTimeoutException: Read timed out
	at java.net.SocketInputStream.socketRead0(Native Method)
	at java.net.SocketInputStream.socketRead(Unknown Source)
	at java.net.SocketInputStream.read(Unknown Source)
	at java.net.SocketInputStream.read(Unknown Source)
	at java.io.BufferedInputStream.fill(Unknown Source)
	at java.io.BufferedInputStream.read1(Unknown Source)
	at java.io.BufferedInputStream.read(Unknown Source)
	at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)
	at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
	at java.net.HttpURLConnection.getResponseCode(Unknown Source)
	at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.getResponse(GatewayInterface.java:421)
	... 14 more

Ignition v7.9.10 (b2018112821)
Java: Oracle Corporation 1.8.0_211

0 Likes

#6

I have no idea what I am missing here. Is there any documentation to read or something to look at that can even lead me towards a solution?

0 Likes