diff --git a/README-CN.md b/README-CN.md index 2a2546c..59d7072 100644 --- a/README-CN.md +++ b/README-CN.md @@ -114,6 +114,7 @@ ConnectionStringBuilder 支持的参数如下: * connTimeout: WebSocket 连接超时时间,仅当 protocol 为 WebSocket 时有效,默认为 1 分钟,使用 `TimeSpan.Parse` 方法解析字符串为 `TimeSpan` 对象。 * readTimeout: WebSocket 读超时时间,仅当 protocol 为 WebSocket 时有效,默认为 5 分钟,使用 `TimeSpan.Parse` 方法解析字符串为 `TimeSpan` 对象。 * writeTimeout: WebSocket 写超时时间,仅当 protocol 为 WebSocket 时有效,默认为 10 秒,使用 `TimeSpan.Parse` 方法解析字符串为 `TimeSpan` 对象。 +* enableCompression: 是否启用 WebSocket 压缩(dotnet 版本 6 及以上,连接器版本 3.1.1 及以上生效),默认为 false ### 指定 URL 和 Properties 获取连接 @@ -747,6 +748,7 @@ consumer 支持的配置参数如下: * auto.commit.interval.ms: 自动提交 offset 的间隔时间,默认为 5000 毫秒 * auto.offset.reset: 当 offset 不存在时,从哪里开始消费,可选值为 earliest 或 latest,默认为 latest * msg.with.table.name: 消息是否包含表名 +* ws.message.enableCompression: 是否启用 WebSocket 压缩(dotnet 版本 6 及以上,连接器版本 3.1.1 及以上生效),默认为 false 支持订阅结果集 `Dictionary` key 为列名,value 为列值。 diff --git a/README.md b/README.md index d0a107d..247f85f 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,7 @@ The parameters supported by `ConnectionStringBuilder` are as follows: * connTimeout: WebSocket connection timeout, only valid when the protocol is WebSocket, the default is 1 minute, use the `TimeSpan.Parse` method to parse the string into a `TimeSpan` object. * readTimeout: WebSocket read timeout, only valid when the protocol is WebSocket, the default is 5 minutes, use the `TimeSpan.Parse` method to parse the string into a `TimeSpan` object. * writeTimeout: WebSocket write timeout, only valid when the protocol is WebSocket, the default is 10 seconds, use the `TimeSpan.Parse` method to parse the string into a `TimeSpan` object. +* enableCompression: Whether to enable WebSocket compression (effective for dotnet version 6 and above, connector version 3.1.1 and above). The default is false. ### Specify the URL and Properties to get the connection @@ -747,6 +748,7 @@ The configuration parameters supported by consumer are as follows: * auto.commit.interval.ms: The interval for automatically submitting offsets, the default is 5000 milliseconds * auto.offset.reset: When offset does not exist, where to start consumption, the optional value is earliest or latest, the default is latest * msg.with.table.name: Whether the message contains the table name +* ws.message.enableCompression: Whether to enable WebSocket compression (effective for dotnet version 6 and above, connector version 3.1.1 and above). The default is false. Supports subscribing to the result set `Dictionary` where the key is the column name and the value is the column value. diff --git a/src/Driver/Client/Websocket/WSClient.cs b/src/Driver/Client/Websocket/WSClient.cs index ec865ee..a063482 100644 --- a/src/Driver/Client/Websocket/WSClient.cs +++ b/src/Driver/Client/Websocket/WSClient.cs @@ -14,7 +14,8 @@ public WSClient(ConnectionStringBuilder builder) Debug.Assert(builder.Protocol == TDengineConstant.ProtocolWebSocket); _tz = builder.Timezone; _connection = new Connection(GetUrl(builder), builder.Username, builder.Password, - builder.Database, builder.ConnTimeout, builder.ReadTimeout, builder.WriteTimeout); + builder.Database, builder.ConnTimeout, builder.ReadTimeout, builder.WriteTimeout, + builder.EnableCompression); _connection.Connect(); } @@ -97,6 +98,7 @@ public long Exec(string query, long reqId) { _connection.FreeResult(resp.ResultId); } + return resp.AffectedRows; } diff --git a/src/Driver/ConnectionStringBuilder.cs b/src/Driver/ConnectionStringBuilder.cs index 02e420c..ef50d43 100644 --- a/src/Driver/ConnectionStringBuilder.cs +++ b/src/Driver/ConnectionStringBuilder.cs @@ -20,6 +20,7 @@ public class ConnectionStringBuilder : DbConnectionStringBuilder private const string WriteTimeoutKey = "writeTimeout"; private const string TokenKey = "token"; private const string UseSSLKey = "useSSL"; + private const string EnableCompressionKey = "enableCompression"; private enum KeysEnum { @@ -34,7 +35,9 @@ private enum KeysEnum ReadTimeout, WriteTimeout, Token, - UseSSL + UseSSL, + EnableCompression, + Total } private string _host = string.Empty; @@ -49,13 +52,14 @@ private enum KeysEnum private TimeSpan _writeTimeout = TimeSpan.Zero; private string _token = string.Empty; private bool _useSSL = false; + private bool _enableCompression = false; private static readonly IReadOnlyList KeysList; private static readonly IReadOnlyDictionary KeysDict; static ConnectionStringBuilder() { - var list = new string[12]; + var list = new string[(int)KeysEnum.Total]; list[(int)KeysEnum.Host] = HostKey; list[(int)KeysEnum.Port] = PortKey; list[(int)KeysEnum.Database] = DatabaseKey; @@ -68,9 +72,10 @@ static ConnectionStringBuilder() list[(int)KeysEnum.WriteTimeout] = WriteTimeoutKey; list[(int)KeysEnum.Token] = TokenKey; list[(int)KeysEnum.UseSSL] = UseSSLKey; + list[(int)KeysEnum.EnableCompression] = EnableCompressionKey; KeysList = list; - KeysDict = new Dictionary(12, StringComparer.OrdinalIgnoreCase) + KeysDict = new Dictionary((int)KeysEnum.Total, StringComparer.OrdinalIgnoreCase) { [HostKey] = KeysEnum.Host, [PortKey] = KeysEnum.Port, @@ -83,7 +88,8 @@ static ConnectionStringBuilder() [ReadTimeoutKey] = KeysEnum.ReadTimeout, [WriteTimeoutKey] = KeysEnum.WriteTimeout, [TokenKey] = KeysEnum.Token, - [UseSSLKey] = KeysEnum.UseSSL + [UseSSLKey] = KeysEnum.UseSSL, + [EnableCompressionKey] = KeysEnum.EnableCompression }; } @@ -145,6 +151,9 @@ public ConnectionStringBuilder(string connectionString) case KeysEnum.UseSSL: UseSSL = Convert.ToBoolean(value); break; + case KeysEnum.EnableCompression: + EnableCompression = Convert.ToBoolean(value); + break; default: throw new ArgumentOutOfRangeException(nameof(index), index, "get value error"); } @@ -230,6 +239,12 @@ public bool UseSSL get => _useSSL; set => base[UseSSLKey] = _useSSL = value; } + + public bool EnableCompression + { + get => _enableCompression; + set => base[EnableCompressionKey] = _enableCompression = value; + } public override ICollection Keys => new ReadOnlyCollection((string[])KeysList); @@ -275,6 +290,8 @@ private object GetAt(KeysEnum index) return Token; case KeysEnum.UseSSL: return UseSSL; + case KeysEnum.EnableCompression: + return EnableCompression; default: throw new ArgumentOutOfRangeException(nameof(index), index, "get value error"); } @@ -334,6 +351,9 @@ private void Reset(KeysEnum index) case KeysEnum.UseSSL: _useSSL = false; return; + case KeysEnum.EnableCompression: + _enableCompression = false; + return; default: throw new ArgumentOutOfRangeException(nameof(index), index, null); } diff --git a/src/Driver/Impl/WebSocketMethods/BaseConnection.cs b/src/Driver/Impl/WebSocketMethods/BaseConnection.cs index 7567129..b660100 100644 --- a/src/Driver/Impl/WebSocketMethods/BaseConnection.cs +++ b/src/Driver/Impl/WebSocketMethods/BaseConnection.cs @@ -24,11 +24,22 @@ public class BaseConnection private readonly TimeSpan _defaultWriteTimeout = TimeSpan.FromSeconds(10); protected BaseConnection(string addr, TimeSpan connectTimeout = default, - TimeSpan readTimeout = default, TimeSpan writeTimeout = default) + TimeSpan readTimeout = default, TimeSpan writeTimeout = default, bool enableCompression = false) { _client = new ClientWebSocket(); _client.Options.KeepAliveInterval = TimeSpan.FromSeconds(30); - +#if NET6_0_OR_GREATER + if (enableCompression) + { + _client.Options.DangerousDeflateOptions = new WebSocketDeflateOptions() + { + ClientMaxWindowBits = 15, // Default value + ServerMaxWindowBits = 15, // Default value + ClientContextTakeover = true, // Default value + ServerContextTakeover = true // Default value + }; + } +#endif if (connectTimeout == default) { connectTimeout = _defaultConnTimeout; @@ -105,8 +116,10 @@ protected T2 SendJsonBackJson(string action, T1 req) where T2 : IWSBaseR // Console.WriteLine(Encoding.UTF8.GetString(respBytes)); if (resp.Action != action) { - throw new TDengineError(-1, $"receive unexpected action {resp.Action},req:{reqStr}",Encoding.UTF8.GetString(respBytes)); + throw new TDengineError(-1, $"receive unexpected action {resp.Action},req:{reqStr}", + Encoding.UTF8.GetString(respBytes)); } + if (resp.Code == 0) return resp; throw new TDengineError(resp.Code, resp.Message); } diff --git a/src/Driver/Impl/WebSocketMethods/Connection.cs b/src/Driver/Impl/WebSocketMethods/Connection.cs index e7f25be..eb3e9cd 100644 --- a/src/Driver/Impl/WebSocketMethods/Connection.cs +++ b/src/Driver/Impl/WebSocketMethods/Connection.cs @@ -12,7 +12,7 @@ public partial class Connection : BaseConnection private readonly string _db = string.Empty; public Connection(string addr, string user, string password, string db, TimeSpan connectTimeout = default, - TimeSpan readTimeout = default, TimeSpan writeTimeout = default) : base(addr, connectTimeout, readTimeout, writeTimeout) + TimeSpan readTimeout = default, TimeSpan writeTimeout = default, bool enableCompression = false) : base(addr, connectTimeout, readTimeout, writeTimeout,enableCompression) { _user = user; _password = password; diff --git a/src/Driver/Impl/WebSocketMethods/TMQ.cs b/src/Driver/Impl/WebSocketMethods/TMQ.cs index 740552e..fb12983 100644 --- a/src/Driver/Impl/WebSocketMethods/TMQ.cs +++ b/src/Driver/Impl/WebSocketMethods/TMQ.cs @@ -7,8 +7,9 @@ namespace TDengine.Driver.Impl.WebSocketMethods public class TMQConnection : BaseConnection { public TMQConnection(TMQOptions options, TimeSpan connectTimeout = default, - TimeSpan readTimeout = default, TimeSpan writeTimeout = default) : base(GetUrl(options), connectTimeout, readTimeout, - writeTimeout) + TimeSpan readTimeout = default, TimeSpan writeTimeout = default) : base( + GetUrl(options), connectTimeout, readTimeout, + writeTimeout, options.TDEnableCompression == "true") { } @@ -41,7 +42,7 @@ private static string GetUrl(TMQOptions options) return $"{schema}://{options.TDConnectIp}:{port}/rest/tmq?token={options.TDToken}"; } } - + public WSTMQSubscribeResp Subscribe(List topics, TMQOptions options) { return Subscribe(_GetReqId(), topics, options); @@ -153,8 +154,9 @@ public WSTMQGetTopicAssignmentResp Assignment(ulong reqId, string topic) public WSTMQOffsetSeekResp Seek(string topic, int vgroupId, long offset) { - return Seek(_GetReqId(), topic,vgroupId, offset); + return Seek(_GetReqId(), topic, vgroupId, offset); } + public WSTMQOffsetSeekResp Seek(ulong reqId, string topic, int vgroupId, long offset) { return SendJsonBackJson(WSTMQAction.TMQSeek, @@ -186,8 +188,9 @@ public WSTMQCommitOffsetResp CommitOffset(ulong reqId, string topic, int vgroupI public WSTMQCommittedResp Committed(List tvIds) { - return Committed(_GetReqId(),tvIds); + return Committed(_GetReqId(), tvIds); } + public WSTMQCommittedResp Committed(ulong reqId, List tvIds) { return SendJsonBackJson(WSTMQAction.TMQCommitted, @@ -202,6 +205,7 @@ public WSTMQPositionResp Position(List tvIds) { return Position(_GetReqId(), tvIds); } + public WSTMQPositionResp Position(ulong reqId, List tvIds) { return SendJsonBackJson(WSTMQAction.TMQPosition, @@ -243,10 +247,12 @@ public class TMQOptions public string MsgWithTableName => Get("msg.with.table.name"); public string TDConnectIp => Get("td.connect.ip"); - + public string TDUseSSL => Get("useSSL"); - + public string TDToken => Get("token"); + + public string TDEnableCompression => Get("ws.message.enableCompression"); public string TDConnectUser => Get("td.connect.user"); @@ -255,7 +261,7 @@ public class TMQOptions public string TDConnectPort => Get("td.connect.port"); public string TDDatabase => Get("td.connect.db"); - + public string TDConnectType => Get("td.connect.type"); public TMQOptions(IEnumerable> config) diff --git a/src/TMQ/ConsumerConfig.cs b/src/TMQ/ConsumerConfig.cs index 4a9a92c..624d6ef 100644 --- a/src/TMQ/ConsumerConfig.cs +++ b/src/TMQ/ConsumerConfig.cs @@ -69,6 +69,12 @@ public string TDToken get => Get("token"); set => this.SetObject("token", value); } + + public string TDEnableCompression + { + get => Get("ws.message.enableCompression"); + set => this.SetObject("ws.message.enableCompression", value); + } public string TDConnectUser { diff --git a/test/Data.Tests/TDengineDataReaderTesting.cs b/test/Data.Tests/TDengineDataReaderTesting.cs index 287e1e6..9d666b0 100644 --- a/test/Data.Tests/TDengineDataReaderTesting.cs +++ b/test/Data.Tests/TDengineDataReaderTesting.cs @@ -126,7 +126,7 @@ public void CommonExec() Assert.Equal((sbyte)7, (sbyte)reader.GetByte(7)); Assert.Equal(true, reader.GetValue(8)); - Assert.Equal(true, reader.GetBoolean(8)); + Assert.True(reader.GetBoolean(8)); Assert.Equal("9nchar", reader.GetValue(9)); Assert.Equal("9nchar", reader.GetString(9)); @@ -255,7 +255,7 @@ public void Statement() Assert.Equal((sbyte)7, (sbyte)reader.GetByte(7)); Assert.Equal(true, reader.GetValue(8)); - Assert.Equal(true, reader.GetBoolean(8)); + Assert.True(reader.GetBoolean(8)); Assert.Equal("9nchar", reader.GetValue(9)); Assert.Equal("9nchar", reader.GetString(9)); @@ -385,7 +385,7 @@ public void StatementNano() Assert.Equal((sbyte)7, (sbyte)reader.GetByte(7)); Assert.Equal(true, reader.GetValue(8)); - Assert.Equal(true, reader.GetBoolean(8)); + Assert.True(reader.GetBoolean(8)); Assert.Equal("9nchar", reader.GetValue(9)); Assert.Equal("9nchar", reader.GetString(9)); @@ -469,7 +469,7 @@ public void WSCommonExec() Assert.Equal((sbyte)7, (sbyte)reader.GetByte(7)); Assert.Equal(true, reader.GetValue(8)); - Assert.Equal(true, reader.GetBoolean(8)); + Assert.True(reader.GetBoolean(8)); Assert.Equal("9nchar", reader.GetValue(9)); Assert.Equal("9nchar", reader.GetString(9)); @@ -598,7 +598,7 @@ public void WSStatement() Assert.Equal((sbyte)7, (sbyte)reader.GetByte(7)); Assert.Equal(true, reader.GetValue(8)); - Assert.Equal(true, reader.GetBoolean(8)); + Assert.True(reader.GetBoolean(8)); Assert.Equal("9nchar", reader.GetValue(9)); Assert.Equal("9nchar", reader.GetString(9)); @@ -728,7 +728,7 @@ public void WSStatementNano() Assert.Equal((sbyte)7, (sbyte)reader.GetByte(7)); Assert.Equal(true, reader.GetValue(8)); - Assert.Equal(true, reader.GetBoolean(8)); + Assert.True(reader.GetBoolean(8)); Assert.Equal("9nchar", reader.GetValue(9)); Assert.Equal("9nchar", reader.GetString(9)); diff --git a/test/Driver.Test/Client/Native/Client.cs b/test/Driver.Test/Client/Native/Client.cs index e8f5929..0547e62 100644 --- a/test/Driver.Test/Client/Native/Client.cs +++ b/test/Driver.Test/Client/Native/Client.cs @@ -360,9 +360,9 @@ public void TDengineNativeStmtTest() Assert.True(isInsert); stmt.SetTableName("t1"); stmt.SetTags(new object[] { "{\"a\":\"b\"}" }); - stmt.BindRow(new Object[] + stmt.BindRow(new object[] { now, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, "test_binary", "test_nchar" }); - stmt.BindRow(new Object[] + stmt.BindRow(new object?[] { nextSecond, null, null, null, null, null, null, null, null, null, null, null, null, null }); stmt.AddBatch(); stmt.Exec(); @@ -494,9 +494,9 @@ public void TDengineNativeStmtNanoTest() var tagFields = stmt.GetTagFields(); Assert.Single(tagFields); stmt.SetTags(new object[] { "{\"a\":\"b\"}" }); - stmt.BindRow(new Object[] + stmt.BindRow(new object[] { now, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, "test_binary", "test_nchar" }); - stmt.BindRow(new Object[] + stmt.BindRow(new object?[] { nextSecond, null, null, null, null, null, null, null, null, null, null, null, null, null }); stmt.AddBatch(); stmt.Exec(); @@ -629,9 +629,9 @@ public void TDengineNativeStmtNanoReqTest() Assert.True(isInsert); stmt.SetTableName("t1"); stmt.SetTags(new object[] { "{\"a\":\"b\"}" }); - stmt.BindRow(new Object[] + stmt.BindRow(new object[] { now, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, "test_binary", "test_nchar" }); - stmt.BindRow(new Object[] + stmt.BindRow(new object?[] { nextSecond, null, null, null, null, null, null, null, null, null, null, null, null, null }); stmt.AddBatch(); stmt.Exec(); @@ -792,7 +792,7 @@ public void TDengineNativeStmtBindColumnsTest() var a9 = new ulong?[] { v9, null, vv9 }; var a10 = new float?[] { v10, null, vv10 }; var a11 = new double?[]{v11,null,vv11}; - stmt.BindColumn(fields,new DateTime[]{now,nextSecond,next2Second},a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,new string[]{ "test_binary",null,"b中文b"},new string[]{ "test_nchar",null,"n中文n"}); + stmt.BindColumn(fields,new DateTime[]{now,nextSecond,next2Second},a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,new string?[]{ "test_binary",null,"b中文b"},new string?[]{ "test_nchar",null,"n中文n"}); stmt.AddBatch(); stmt.Exec(); var affected = stmt.Affected(); diff --git a/test/Driver.Test/Client/TMQ/WS/Consumer.cs b/test/Driver.Test/Client/TMQ/WS/Consumer.cs index e47282a..933de27 100644 --- a/test/Driver.Test/Client/TMQ/WS/Consumer.cs +++ b/test/Driver.Test/Client/TMQ/WS/Consumer.cs @@ -23,7 +23,7 @@ public void NewConsumerTest() { var builder = new ConnectionStringBuilder( - "protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata"); + "protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata;enableCompression=true"); using (var client = DbDriver.Open(builder)) { try @@ -83,6 +83,7 @@ public void NewConsumerTest() { "enable.auto.commit", "false" }, { "msg.with.table.name", "true" }, { "useSSL", "false" }, + { "ws.message.enableCompression", "true" } }; DoRequest(client, "use af_test_tmq_ws"); var consumer = new ConsumerBuilder>(cfg).Build(); @@ -158,7 +159,7 @@ public void ConsumerSeekTest() { var builder = new ConnectionStringBuilder( - "protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata"); + "protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata;enableCompression=true"); using (var client = DbDriver.Open(builder)) { try @@ -218,6 +219,7 @@ public void ConsumerSeekTest() { "enable.auto.commit", "false" }, { "msg.with.table.name", "true" }, { "useSSL", "false" }, + { "ws.message.enableCompression", "true" } }; var consumer = new ConsumerBuilder>(cfg).Build(); @@ -333,7 +335,7 @@ public void ConsumerCommitTest() { var builder = new ConnectionStringBuilder( - "protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata"); + "protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata;enableCompression=true"); using (var client = DbDriver.Open(builder)) { try @@ -392,7 +394,8 @@ public void ConsumerCommitTest() { "client.id", "test_tmq_c" }, { "enable.auto.commit", "false" }, { "msg.with.table.name", "true" }, - { "useSSL", "false" } + { "useSSL", "false" }, + { "ws.message.enableCompression", "true" } }; var consumer = new ConsumerBuilder>(cfg).Build(); diff --git a/test/Driver.Test/Client/WS/Client.cs b/test/Driver.Test/Client/WS/Client.cs index fe90355..4227a5a 100644 --- a/test/Driver.Test/Client/WS/Client.cs +++ b/test/Driver.Test/Client/WS/Client.cs @@ -40,7 +40,7 @@ public void TDengineWSDriverTest() var builder = new ConnectionStringBuilder( - "protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata"); + "protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata;enableCompression=true"); using (var client = DbDriver.Open(builder)) { try @@ -135,7 +135,7 @@ public void TDengineWSDriverNanoTest() var builder = new ConnectionStringBuilder( - "protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata"); + "protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata;enableCompression=true"); using (var client = DbDriver.Open(builder)) { try @@ -234,7 +234,7 @@ public void TDengineWSDriverNanoReqTest() var builder = new ConnectionStringBuilder( - "protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata"); + "protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata;enableCompression=true"); using (var client = DbDriver.Open(builder)) { try @@ -334,7 +334,7 @@ public void TDengineWSStmtTest() var builder = new ConnectionStringBuilder( - "protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata"); + "protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata;enableCompression=true"); using (var client = DbDriver.Open(builder)) { try @@ -365,9 +365,9 @@ public void TDengineWSStmtTest() Assert.True(isInsert); stmt.SetTableName("t1"); stmt.SetTags(new object[] { "{\"a\":\"b\"}" }); - stmt.BindRow(new Object[] + stmt.BindRow(new object[] { now, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, "test_binary", "test_nchar" }); - stmt.BindRow(new Object[] + stmt.BindRow(new object?[] { nextSecond, null, null, null, null, null, null, null, null, null, null, null, null, null }); stmt.AddBatch(); stmt.Exec(); @@ -438,14 +438,15 @@ public void TDengineWSStmtTest() } } } - + [Fact] public void TDengineInfluxDBTest() { var db = "sml_influx_ws"; var builder = - new ConnectionStringBuilder("protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata"); + new ConnectionStringBuilder( + "protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata;enableCompression=true"); using (var client = DbDriver.Open(builder)) { try @@ -565,7 +566,8 @@ public void TDengineTelnetTest() var db = "sml_telnet_ws"; var builder = - new ConnectionStringBuilder("protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata"); + new ConnectionStringBuilder( + "protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata;enableCompression=true"); using (var client = DbDriver.Open(builder)) { try @@ -599,7 +601,8 @@ public void TDengineJsonTest() var db = "sml_json_ws"; var builder = - new ConnectionStringBuilder("protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata"); + new ConnectionStringBuilder( + "protocol=WebSocket;host=localhost;port=6041;useSSL=false;username=root;password=taosdata;enableCompression=true"); using (var client = DbDriver.Open(builder)) { try diff --git a/test/Driver.Test/Function.Test/BlockWriter.cs b/test/Driver.Test/Function.Test/BlockWriter.cs index 673ad25..4ee25ba 100644 --- a/test/Driver.Test/Function.Test/BlockWriter.cs +++ b/test/Driver.Test/Function.Test/BlockWriter.cs @@ -79,14 +79,14 @@ public void TestAllType() var ai64 = new long?[] { v5, null, vv5 }; var af = new float?[] { v10, null, vv10 }; var ad = new double?[] { v11, null, vv11 }; - var av = new string[] { "test1", null, "中文" }; + var av = new string?[] { "test1", null, "中文" }; var au8 = new byte?[] { v6, null, vv6 }; var au16 = new ushort?[] { v7, null, vv7 }; var au32 = new uint?[] { v8, null, vv8 }; var au64 = new ulong?[] { v9, null, vv9 }; var at = new long[] { 1692754030419, 1692754031419, 1692754032419 }; - var an = new string[] { "中文n", null, "n中文" }; - var aj = new string[] { "{\"a\":\"b\"}", null, "{\"a\":\"b\"}" }; + var an = new string?[] { "中文n", null, "n中文" }; + var aj = new string?[] { "{\"a\":\"b\"}", null, "{\"a\":\"b\"}" }; var block = BlockWriter.Serialize(3, allType, ab, ai8, ai16, ai32, ai64, af, ad, av, at, an, au8, au16, au32, au64, aj); var expect = new byte[] diff --git a/test/Driver.Test/Function.Test/SubscribeTables.cs b/test/Driver.Test/Function.Test/SubscribeTables.cs index 5ed5fc7..f69a61c 100644 --- a/test/Driver.Test/Function.Test/SubscribeTables.cs +++ b/test/Driver.Test/Function.Test/SubscribeTables.cs @@ -335,8 +335,8 @@ public class TMQResult public ulong u8 { get; set; } public float f4 { get; set; } public double f8 { get; set; } - public byte[] bin { get; set; } - public string nchr { get; set; } + public byte[]? bin { get; set; } + public string? nchr { get; set; } public bool b { get; set; } } } \ No newline at end of file