尝试将流事件附加到 EventStore 会抛出异常
Trying to append a stream event to EventStore throws Exception
我目前正在开始使用 EventStore and I'm following the Getting Started 指南。而且我只是卡在了第一步,不知道我做错了什么......
我现在用的版本是20.6.0.
我正在尝试使用 .NET Core 客户端将事件写入我的本地实例(运行,因为我可以使用 AdminUI 添加事件)。但是我得到了一个例外,比如 One or more errors occurred. (Connection 'ES-41230054-2026-4cdb-b2bb-a35824779863' was closed.)'
.
尝试修复一段时间后,我转到 .Net Client guide 并粘贴了完全相同的一段代码:
public static void Main()
{
var conn = EventStoreConnection.Create(new Uri("tcp://admin:changeit@localhost:1113"));
conn.ConnectAsync().Wait();
var data = Encoding.UTF8.GetBytes("{\"a\":\"2\"}");
var metadata = Encoding.UTF8.GetBytes("{}");
var evt = new EventData(Guid.NewGuid(), "testEvent", true, data, metadata);
conn.AppendToStreamAsync("test-stream", ExpectedVersion.Any, evt).Wait();
var streamEvents = conn.ReadStreamEventsForwardAsync("test-stream", 0, 1, false).Result;
var returnedEvent = streamEvents.Events[0].Event;
Console.WriteLine("Read event with data: {0}, metadata: {1}",
Encoding.UTF8.GetString(returnedEvent.Data),
Encoding.UTF8.GetString(returnedEvent.Metadata));
}
}
但是当我到达这一行时抛出同样的异常:
conn.AppendToStreamAsync("test-stream", ExpectedVersion.Any, evt).Wait();
我在创建连接时尝试了不同的方法,但 none 目前有效。
我想知道我是否遗漏了一些配置...如果有人遇到过这个问题并愿意为我提供一些帮助,我将不胜感激。
正在添加更多信息
激活日志记录后,我看到了以下内容:
- 尝试附加事件时,我得到以下输出:
[01,07:28:46.528,DEBUG] EventStoreConnection 'ES-90357f8a-6c79-4638-909a-142c8ddb9a8b': enqueueing message EventStore.ClientAPI.Internal.StartConnectionMessage..
[04,07:28:46.545,DEBUG] EventStoreConnection 'ES-90357f8a-6c79-4638-909a-142c8ddb9a8b': StartConnection.
[04,07:28:46.546,DEBUG] EventStoreConnection 'ES-90357f8a-6c79-4638-909a-142c8ddb9a8b': DiscoverEndPoint.
[04,07:28:46.549,DEBUG] EventStoreConnection 'ES-90357f8a-6c79-4638-909a-142c8ddb9a8b': enqueueing message EventStore.ClientAPI.Internal.EstablishTcpConnectionMessage..
[06,07:28:46.561,DEBUG] EventStoreConnection 'ES-90357f8a-6c79-4638-909a-142c8ddb9a8b': EstablishTcpConnection to [127.0.0.1:1113].
[05,07:28:46.582,DEBUG] EventStoreConnection 'ES-90357f8a-6c79-4638-909a-142c8ddb9a8b': enqueueing message EventStore.ClientAPI.Internal.StartOperationMessage..
[06,07:28:46.642,DEBUG] EventStoreConnection 'ES-90357f8a-6c79-4638-909a-142c8ddb9a8b': StartOperation enqueue AppendToStreamOperation, Stream: newstream, ExpectedVersion: -2, 10, 00:00:07..
[06,07:28:46.643,DEBUG] EventStoreConnection 'ES-90357f8a-6c79-4638-909a-142c8ddb9a8b': EnqueueOperation WAITING for Operation AppendToStreamOperation (a301f19c-bb92-4c53-a193-3a81582a49db): Stream: newstream, ExpectedVersion: -2, retry count: 0, created: 07:28:46.642, last updated: 07:28:46.642..
[08,07:28:48.702,DEBUG] TcpPackageConnection: connection to [127.0.0.1:1113, L, {69f92d44-54ab-4643-b540-23f89b796fcf}] failed. Error: ConnectionRefused.
[08,07:28:48.703,DEBUG] EventStoreConnection 'ES-90357f8a-6c79-4638-909a-142c8ddb9a8b': enqueueing message EventStore.ClientAPI.Internal.TcpConnectionClosedMessage..
[08,07:28:48.704,DEBUG] EventStoreConnection 'ES-90357f8a-6c79-4638-909a-142c8ddb9a8b': TCP connection to [127.0.0.1:1113, L, {69f92d44-54ab-4643-b540-23f89b796fcf}] closed..
[06,07:28:48.924,DEBUG] EventStoreConnection 'ES-90357f8a-6c79-4638-909a-142c8ddb9a8b': TimerTick checking reconnection....
[06,07:28:49.213,DEBUG] EventStoreConnection 'ES-90357f8a-6c79-4638-909a-142c8ddb9a8b': ExecuteOperation package WriteEvents, a301f19c-bb92-4c53-a193-3a81582a49db, Operation AppendToStreamOperation (a301f19c-bb92-4c53-a193-3a81582a49db): Stream: newstream, ExpectedVersion: -2, retry count: 0, created: 07:28:46.642, last updated: 07:28:48.935..
[06,07:28:49.229,DEBUG] EventStoreConnection 'ES-90357f8a-6c79-4638-909a-142c8ddb9a8b': DiscoverEndPoint.
[06,07:28:49.230,DEBUG] EventStoreConnection 'ES-90357f8a-6c79-4638-909a-142c8ddb9a8b': enqueueing message EventStore.ClientAPI.Internal.EstablishTcpConnectionMessage..
[04,07:28:49.231,DEBUG] EventStoreConnection 'ES-90357f8a-6c79-4638-909a-142c8ddb9a8b': EstablishTcpConnection to [127.0.0.1:1113].
所以这似乎是说问题出在端口没有打开,我尝试完全禁用防火墙但没有成功。
- 另外,当我执行命令
EventStore.ClusterNode.exe --db ./db --log ./logs --dev
时,我在输出中注意到了这一点:
如果我这样做 telnet 127.0.0.1 1113
它似乎无法连接,但我没有发现问题所在。有什么想法吗?
我遇到了完全相同的问题@devcrp
- 当你启动服务器时,你的带有“接口”的图像直接指向了丢失的标志。
解决方案(对于 20.6.0 > )是在启动事件存储时添加此标志
--enable-external-tcp
我遇到了类似的问题,在管理 UI 中禁用了“流浏览器”,它需要
--enable-atom-pub-over-http
还有一些其他问题
就像不知道访问管理员需要 https UI,http 在文档中有说明但不起作用(在 20.6.0 中也是新的)以及如何让配置文件工作(也是由于过时的标记,ExtSecureTcpPort,在文档中,并且缺少有关 TrustedRootCertificatesPath 的信息)
- 这里有一些关于使用 config.yaml 和 TrustedRootCertificatesPath https://gist.github.com/JimiSweden/f8916a94bd3dab1ff07c940b9169c946
的信息
如果您查看控制台中“接口”之后的“弃用警告”行,就会提示为什么需要启用 atom-pub-over-http 和 external-tcp
Here is my console output with external-tcp and atom-pub-over-http enabled
what you see here has nothing to do with firewalls etc, it is solely the output from event store.
[28224, 1,22:27:51.677,INF]
INTERFACES
External TCP (Protobuf)
Enabled : True
Port : 1113
HTTP (AtomPub)
Enabled : True
Port : 2113
[28224, 1,22:27:51.678,WRN]
DEPRECATION WARNING: AtomPub over HTTP Interface has been deprecated as of version 20.02. It is recommended to use gRPC instead.
[28224, 1,22:27:51.678,WRN]
DEPRECATION WARNING: The Legacy TCP Client Interface has been deprecated as of version 20.02. The External TCP Interface can be re-enabled with the 'EnableExternalTCP' option. It is recommended to use gRPC instead.
This is my working start command
(in a file called '.\eventstore start command.ps1' to make it simpler to run the server)
EventStore.ClusterNode.exe --db ./db --log ./logs --config=config.yaml --enable-atom-pub-over-http --enable-external-tcp --run-projections=all --start-standard-projections=true
我目前正在开始使用 EventStore and I'm following the Getting Started 指南。而且我只是卡在了第一步,不知道我做错了什么......
我现在用的版本是20.6.0.
我正在尝试使用 .NET Core 客户端将事件写入我的本地实例(运行,因为我可以使用 AdminUI 添加事件)。但是我得到了一个例外,比如 One or more errors occurred. (Connection 'ES-41230054-2026-4cdb-b2bb-a35824779863' was closed.)'
.
尝试修复一段时间后,我转到 .Net Client guide 并粘贴了完全相同的一段代码:
public static void Main()
{
var conn = EventStoreConnection.Create(new Uri("tcp://admin:changeit@localhost:1113"));
conn.ConnectAsync().Wait();
var data = Encoding.UTF8.GetBytes("{\"a\":\"2\"}");
var metadata = Encoding.UTF8.GetBytes("{}");
var evt = new EventData(Guid.NewGuid(), "testEvent", true, data, metadata);
conn.AppendToStreamAsync("test-stream", ExpectedVersion.Any, evt).Wait();
var streamEvents = conn.ReadStreamEventsForwardAsync("test-stream", 0, 1, false).Result;
var returnedEvent = streamEvents.Events[0].Event;
Console.WriteLine("Read event with data: {0}, metadata: {1}",
Encoding.UTF8.GetString(returnedEvent.Data),
Encoding.UTF8.GetString(returnedEvent.Metadata));
}
}
但是当我到达这一行时抛出同样的异常:
conn.AppendToStreamAsync("test-stream", ExpectedVersion.Any, evt).Wait();
我在创建连接时尝试了不同的方法,但 none 目前有效。
我想知道我是否遗漏了一些配置...如果有人遇到过这个问题并愿意为我提供一些帮助,我将不胜感激。
正在添加更多信息
激活日志记录后,我看到了以下内容:
- 尝试附加事件时,我得到以下输出:
[01,07:28:46.528,DEBUG] EventStoreConnection 'ES-90357f8a-6c79-4638-909a-142c8ddb9a8b': enqueueing message EventStore.ClientAPI.Internal.StartConnectionMessage..
[04,07:28:46.545,DEBUG] EventStoreConnection 'ES-90357f8a-6c79-4638-909a-142c8ddb9a8b': StartConnection.
[04,07:28:46.546,DEBUG] EventStoreConnection 'ES-90357f8a-6c79-4638-909a-142c8ddb9a8b': DiscoverEndPoint.
[04,07:28:46.549,DEBUG] EventStoreConnection 'ES-90357f8a-6c79-4638-909a-142c8ddb9a8b': enqueueing message EventStore.ClientAPI.Internal.EstablishTcpConnectionMessage..
[06,07:28:46.561,DEBUG] EventStoreConnection 'ES-90357f8a-6c79-4638-909a-142c8ddb9a8b': EstablishTcpConnection to [127.0.0.1:1113].
[05,07:28:46.582,DEBUG] EventStoreConnection 'ES-90357f8a-6c79-4638-909a-142c8ddb9a8b': enqueueing message EventStore.ClientAPI.Internal.StartOperationMessage..
[06,07:28:46.642,DEBUG] EventStoreConnection 'ES-90357f8a-6c79-4638-909a-142c8ddb9a8b': StartOperation enqueue AppendToStreamOperation, Stream: newstream, ExpectedVersion: -2, 10, 00:00:07..
[06,07:28:46.643,DEBUG] EventStoreConnection 'ES-90357f8a-6c79-4638-909a-142c8ddb9a8b': EnqueueOperation WAITING for Operation AppendToStreamOperation (a301f19c-bb92-4c53-a193-3a81582a49db): Stream: newstream, ExpectedVersion: -2, retry count: 0, created: 07:28:46.642, last updated: 07:28:46.642..
[08,07:28:48.702,DEBUG] TcpPackageConnection: connection to [127.0.0.1:1113, L, {69f92d44-54ab-4643-b540-23f89b796fcf}] failed. Error: ConnectionRefused.
[08,07:28:48.703,DEBUG] EventStoreConnection 'ES-90357f8a-6c79-4638-909a-142c8ddb9a8b': enqueueing message EventStore.ClientAPI.Internal.TcpConnectionClosedMessage..
[08,07:28:48.704,DEBUG] EventStoreConnection 'ES-90357f8a-6c79-4638-909a-142c8ddb9a8b': TCP connection to [127.0.0.1:1113, L, {69f92d44-54ab-4643-b540-23f89b796fcf}] closed..
[06,07:28:48.924,DEBUG] EventStoreConnection 'ES-90357f8a-6c79-4638-909a-142c8ddb9a8b': TimerTick checking reconnection....
[06,07:28:49.213,DEBUG] EventStoreConnection 'ES-90357f8a-6c79-4638-909a-142c8ddb9a8b': ExecuteOperation package WriteEvents, a301f19c-bb92-4c53-a193-3a81582a49db, Operation AppendToStreamOperation (a301f19c-bb92-4c53-a193-3a81582a49db): Stream: newstream, ExpectedVersion: -2, retry count: 0, created: 07:28:46.642, last updated: 07:28:48.935..
[06,07:28:49.229,DEBUG] EventStoreConnection 'ES-90357f8a-6c79-4638-909a-142c8ddb9a8b': DiscoverEndPoint.
[06,07:28:49.230,DEBUG] EventStoreConnection 'ES-90357f8a-6c79-4638-909a-142c8ddb9a8b': enqueueing message EventStore.ClientAPI.Internal.EstablishTcpConnectionMessage..
[04,07:28:49.231,DEBUG] EventStoreConnection 'ES-90357f8a-6c79-4638-909a-142c8ddb9a8b': EstablishTcpConnection to [127.0.0.1:1113].
所以这似乎是说问题出在端口没有打开,我尝试完全禁用防火墙但没有成功。
- 另外,当我执行命令
EventStore.ClusterNode.exe --db ./db --log ./logs --dev
时,我在输出中注意到了这一点:
如果我这样做 telnet 127.0.0.1 1113
它似乎无法连接,但我没有发现问题所在。有什么想法吗?
我遇到了完全相同的问题@devcrp
- 当你启动服务器时,你的带有“接口”的图像直接指向了丢失的标志。
解决方案(对于 20.6.0 > )是在启动事件存储时添加此标志
--enable-external-tcp
我遇到了类似的问题,在管理 UI 中禁用了“流浏览器”,它需要
--enable-atom-pub-over-http
还有一些其他问题 就像不知道访问管理员需要 https UI,http 在文档中有说明但不起作用(在 20.6.0 中也是新的)以及如何让配置文件工作(也是由于过时的标记,ExtSecureTcpPort,在文档中,并且缺少有关 TrustedRootCertificatesPath 的信息)
- 这里有一些关于使用 config.yaml 和 TrustedRootCertificatesPath https://gist.github.com/JimiSweden/f8916a94bd3dab1ff07c940b9169c946 的信息
如果您查看控制台中“接口”之后的“弃用警告”行,就会提示为什么需要启用 atom-pub-over-http 和 external-tcp
Here is my console output with external-tcp and atom-pub-over-http enabled
what you see here has nothing to do with firewalls etc, it is solely the output from event store.
[28224, 1,22:27:51.677,INF]
INTERFACES
External TCP (Protobuf)
Enabled : True
Port : 1113
HTTP (AtomPub)
Enabled : True
Port : 2113
[28224, 1,22:27:51.678,WRN]
DEPRECATION WARNING: AtomPub over HTTP Interface has been deprecated as of version 20.02. It is recommended to use gRPC instead.
[28224, 1,22:27:51.678,WRN]
DEPRECATION WARNING: The Legacy TCP Client Interface has been deprecated as of version 20.02. The External TCP Interface can be re-enabled with the 'EnableExternalTCP' option. It is recommended to use gRPC instead.
This is my working start command (in a file called '.\eventstore start command.ps1' to make it simpler to run the server)
EventStore.ClusterNode.exe --db ./db --log ./logs --config=config.yaml --enable-atom-pub-over-http --enable-external-tcp --run-projections=all --start-standard-projections=true