Comments (5)
Am I missing something? Im using the TS example listed on the readme..
import {
EventStoreDBClient,
jsonEvent,
FORWARDS,
START,
JSONEventType,
} from "@eventstore/db-client";
const client = new EventStoreDBClient({
endpoint: "localhost:2113",
});
interface Reservation {
reservationId: string;
movieId: string;
userId: string;
seatId: string;
}
type SeatReservedEvent = JSONEventType<
"seat-reserved",
{
reservationId: string;
movieId: string;
userId: string;
seatId: string;
}
>;
type SeatChangedEvent = JSONEventType<
"seat-changed",
{
reservationId: string;
newSeatId: string;
}
>;
type ReservationEvents = SeatReservedEvent | SeatChangedEvent;
async function simpleTest(): Promise<void> {
const streamName = "booking-abc123";
const event = jsonEvent<SeatReservedEvent>({
type: "seat-reserved",
data: {
reservationId: "abc123",
movieId: "tt0368226",
userId: "nm0802995",
seatId: "4b",
},
});
const appendResult = await client.appendToStream(streamName, event);
const events = client.readStream<ReservationEvents>(streamName, {
fromRevision: START,
direction: FORWARDS,
maxCount: 10,
});
const reservation: Partial<Reservation> = {};
for await (const { event } of events) {
switch (event.type) {
case "seat-reserved": {
reservation.reservationId = event.data.reservationId;
reservation.movieId = event.data.movieId;
reservation.seatId = event.data.seatId;
reservation.userId = event.data.userId;
break;
}
case "seat-changed": {
reservation.seatId = event.data.newSeatId;
break;
}
default: {
const _exhaustiveCheck: never = event;
break;
}
}
}
}
And the exact same installation method listed on the official docs: https://developers.eventstore.com/server/v5/installation.html#use-docker-compose
from eventstore-client-nodejs.
Hi Mike,
insecure docker compose
[...]const client = new EventStoreDBClient({ endpoint: "localhost:2113", });
The grpc clients are secure by default, so you need to tell the client to use an insecure connection, you can either do this via the options argument:
const client = new EventStoreDBClient(
{ endpoint: "localhost:2113" },
{ insecure: true }
);
or via a connection string
const client = EventStoreDBClient.connectionString`esdb://localhost:2113?tls=false`;
You can find our connecting string helper here:
https://developers.eventstore.com/clients/grpc/#connection-details
And the exact same installation method listed on the official docs:
https://developers.eventstore.com/server/v5/installation.html#use-docker-compose
You've linked the v5
docs here (though you linked v21.10
in the original issue)
The GRPC clients are only supported on 20.6.1
upwards.
If you're having trouble finding something in the docs, a good place to look for examples are the tests in this repo. For example, under connection/insecure
This could definitely be more explicitly spelled out in the documentation (and isn't the first issue we've had asking this so it must be tripping more people up.) I'll see about adding something.
from eventstore-client-nodejs.
Ah gotcha thanks, I can confirm since adding { insecure: true }
it now works.
I definately think this could be made more clear in the docs or perhaps the error could be more clear UnavailableError: 14 UNAVAILABLE: No connection established
doesnt really tell you much ;)
If you're having trouble finding something in the docs, a good place to look for examples are the tests in this repo. For example, under connection/insecure
Although linking to tests is sometimes useful in this case it doesnt actually show me where I made a mistake as it doesnt show me that I needed to use the special flag:
Also I would have had to go looking for the "insecure" examples which would probably have meant I knew that I was getting a security issue, which I didnt know because of the error.
Anyways I appreciate you getting back to me, I have solved the issue so feel free to close this.
from eventstore-client-nodejs.
I can confirm since adding
{ insecure: true }
it now works.
Great, glad you were able to get it working.
I definately think this could be made more clear in the docs
I've added a note to the top of the docs about this to hopefully point people in the right direction. EventStore/documentation#544
perhaps the error could be more clear
UnavailableError: 14 UNAVAILABLE: No connection established
doesnt really tell you much
Setting the client to insecure changes the endpoint from https://
to http://
so the returned error is just connection refused, meaning we can't distinguish between an incorrect endpoint, or an unavailable server, or a spelling mistake in your endpoint etc. Maybe we could add a debug log with some pointers on what to check.
I have solved the issue so feel free to close this.
Will do.
from eventstore-client-nodejs.
I Had the same problem as @mikecann, It's obviously nice that is secure by default, I think it would be better to add a comment on the example code, since different people arrive to this repo from different places.
And it's most likely that you are running that "hello world" in an insecure way, since I might wrong but all docker examples from the getting started guides are written with --insecure
from eventstore-client-nodejs.
Related Issues (20)
- Is there a way how to force release all resources created by client? HOT 5
- Automatically close batch append connection
- Memory leak
- Memory leak HOT 4
- Wrong comment in readStream.d.ts HOT 1
- Memory Leak on readStream HOT 9
- Retrieving batch of events from catchup subscriptions HOT 3
- Feature Request: gRPC-web adapter. HOT 1
- `emitEnabled` only available on projection update, not on create HOT 2
- Appending more than 100 events at once on a fresh connection fails. (Batch append?) HOT 1
- Add debug log if `serverFeatures` failed
- ServerFeatures should only assume unknown server on `UNIMPLEMENTED` error
- readUint64String is not a function HOT 4
- created is not a javascript safe integer HOT 2
- Gracefull shutdown HOT 1
- Trouble connecting to cloud cluster from AWS HOT 2
- Please ship a sourcemap HOT 2
- Trying to append an event with wrong id results in UnknownError HOT 1
- appendToStream with expectedRevision -1 causes cryptic error HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eventstore-client-nodejs.