简体   繁体   English

Influxdb-java:org.influxdb.InfluxDBIOException:java.net.SocketException:通过对等方重置连接:套接字写入错误

[英]influxdb-java: org.influxdb.InfluxDBIOException: java.net.SocketException: Connection reset by peer: socket write error

I'm testing InfluxDB to store sensor time series. 我正在测试InfluxDB来存储传感器时间序列。 I'm using the influxdb-java client library (version 2.15) and I'm running InfluxDB 1.7.6 locally for test purpose. 我正在使用Influxdb-java客户端库(版本2.15),我在本地运行InfluxDB 1.7.6用于测试目的。

All my points are stored .csv files (one per sensor) which are themselves stored in .zip files (one per dataset). 我的所有点都存储.csv文件(每个传感器一个),它们本身存储在.zip文件中(每个数据集一个)。 My code run through each line of each csv files. 我的代码遍历每个csv文件的每一行。 Points are written in batch mode. 点以批处理模式写入。

/**
 * Get the connection to the database
 */
InfluxDB influxDB = InfluxDBFactory.connect("http://192.168.51.51:8086");
influxDB.query(new Query("CREATE DATABASE theia_in_situ"));
influxDB.setDatabase("theia_in_situ");
influxDB.enableBatch();
influxDB.setLogLevel(InfluxDB.LogLevel.BASIC);
/**
 * Create batch point to write each measure of the time serie more efficiently
 */
BatchPoints batchPoints = BatchPoints
        .database("theia_in_situ")
        .build();

For each CSV data file the following method is executed: 对于每个CSV数据文件,执行以下方法:

public static void createAndImportTimeSeriesDocuments(InputStream txtFileIn, String observationId, String producerId,
        InfluxDB influxDB, BatchPoints batchPoints) throws IOException, ParseException {
    DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
    /**
     * Store the variable name
     */
    String observedProperty = null;
    try (BufferedReader br = new BufferedReader(new InputStreamReader(txtFileIn));) {
        String line = null;
        /**
         * Read the headers
         */
        while ((line = br.readLine()).substring(0, 1).equals("#")) {
            if (line.substring(0, 15).equals("#Variable_name;")) {
                observedProperty = line.split(";")[1];
            }
        }
        /**
         * Read the data
         */
        while ((line = br.readLine()) != null) {
            String[] lineSplitted = line.split(";", -1);
            Point point = Point.measurement(observedProperty)
                    .tag("producerId", producerId)
                    .tag("observationId", observationId)
                    .time(df.parse(lineSplitted[1]).getTime(), TimeUnit.MILLISECONDS)
                    .addField("value", lineSplitted[5])
                    .addField("flag", lineSplitted[6])
                    .build();
            batchPoints.point(point);
        }
        influxDB.write(batchPoints);
    }
}

I can write one or few measurement but soon enough I get the following exception: 我可以写一个或几个测量但很快我得到以下异常:

Exception in thread "main" org.influxdb.InfluxDBIOException: java.net.SocketException: Connection reset by peer: socket write error at org.influxdb.impl.InfluxDBImpl.execute(InfluxDBImpl.java:812) at org.influxdb.impl.InfluxDBImpl.write(InfluxDBImpl.java:463) 线程“main”中的异常org.influxdb.InfluxDBIOException:java.net.SocketException:由org.influxdb.impl上的org.influxdb.impl.InfluxDBImpl.execute(InfluxDBImpl.java:812)中的peer:socket write error重置连接。 InfluxDBImpl.write(InfluxDBImpl.java:463)

I have already disabled max-concurrent-write-limit, max-enqueued-write-limit, enqueued-write-timeout (setting each value to 0 in /etc/influxdb/influxdb.conf ) as mentionned here . 我已经禁用最大并发写入限制,最大入列写入限制,排队写超时(在每个值设置为0 /etc/influxdb/influxdb.conf )作为mentionned 这里 Even though this issue is mentionned as FAQ in the Github page, I can't find any issue reproducing my problem. 即使在Github页面中提到这个问题作为FAQ,我也找不到任何问题来重现我的问题。

Any help would be appreciated. 任何帮助,将不胜感激。

This exception seems to occur when trying to write BatchPoint in batch mode. 尝试以批处理模式编写BatchPoint时,似乎会发生此异常。

The influxdb-java client is storing your writes into an internal buffer and flushes them asynchronously to InfluxDB at a fixed flush interval to achieve good performance on both client and server side. Influxdb-java客户端将您的写入存储到内部缓冲区,并以固定的刷新间隔异步刷新到InfluxDB,以在客户端和服务器端实现良好的性能。

Here is the updated piece of code. 这是更新的代码段。

/**
 * Read the data
 */
while ((line = br.readLine()) != null) {
    String[] lineSplitted = line.split(";", -1);
    Point point = Point.measurement(observedProperty)
            .tag("producerId", producerId)
            .tag("observationId", observationId)
            .time(df.parse(lineSplitted[1]).getTime(), TimeUnit.MILLISECONDS)
            .addField("value", lineSplitted[5])
            .addField("flag", lineSplitted[6])
            .build();
    influxDB.write(point);
  //  batchPoints.point(point);
}
//influxDB.write(batchPoints);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ClientAbortException:java.net.SocketException:由peer重置连接:套接字写入错误 - ClientAbortException: java.net.SocketException: Connection reset by peer: socket write error java.net.SocketException: Connection reset by peer: socket write error 提供文件时 - java.net.SocketException: Connection reset by peer: socket write error When serving a file “ java.net.SocketException:对等体重置连接:套接字写入错误”我该如何解决 - “java.net.SocketException: Connection reset by peer: socket write error” How can I solve it java.net.SocketException:对等连接重置:传输音频时套接字写入错误 - java.net.SocketException: Connection reset by peer: socket write error When transmitting Audio ClientAbortException:java.net.SocketException:对等重置连接:套接字写入错误 - ClientAbortException: java.net.SocketException: Connection reset by peer: socket write error (java.net.SocketException) 在处理请求时被捕获:连接被对等重置:套接字写入错误 - (java.net.SocketException) caught when processing request: Connection reset by peer: socket write error 当发送沉重的json将近5MB时,它将给我java.net.SocketException:连接被同级重置:套接字写入错误 - While sending heavy json almost 5MB it will give me java.net.SocketException: Connection reset by peer: socket write error 我收到 java.net.SocketException: Connection reset by peer: socket write error ,当在类截图中执行主函数时 - I am getting java.net.SocketException: Connection reset by peer: socket write error ,when executing main function in class screenshot java.net.socketexception connection reset by peer socket write error 通过Jenkins在Tomcat7上部署war时(使用Maven) - java.net.socketexception connection reset by peer socket write error While deploying war on Tomcat7 through Jenkins (Using Maven) 错误java.net.SocketException:连接重置 - ERROR java.net.SocketException: Connection reset
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM