Skip to content

Commit 9efa5c7

Browse files
author
Enric Sala
committed
Implement the ping method using webread instead of urlread
The webread function gives much higher ping results, but urlread is deprecated.
1 parent 0c28eef commit 9efa5c7

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ PASS = 'password';
3535
DATABASE = 'server_stats';
3636
influxdb = InfluxDB(HOST, USER, PASS, DATABASE);
3737
38-
% Check if the InfluxDB server is running
38+
% Check the status of the InfluxDB instance
3939
[ok, ping] = influxdb.ping()
4040
4141
% Show the databases in the server

influxdb-client/InfluxDB.m

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,17 @@
2828
obj.WriteTimeout = timeout;
2929
end
3030

31-
% Test the connection with a ping
31+
% Check the status of the InfluxDB instance
3232
function [ok, millis] = ping(obj)
33-
timer = tic;
34-
url = [obj.Host '/ping'];
35-
[~, status] = urlread(url);
36-
millis = toc(timer) * 1000;
37-
ok = logical(status);
33+
try
34+
timer = tic;
35+
webread([obj.Host '/ping']);
36+
millis = toc(timer) * 1000;
37+
ok = true;
38+
catch
39+
millis = Inf;
40+
ok = false;
41+
end
3842
end
3943

4044
% Show databases

0 commit comments

Comments
 (0)