Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
paambaati committed Sep 19, 2019
1 parent f274fa6 commit d516570
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/bug-repro.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { Client, credentials } from 'grpc';
import { SubscribeRequest, CreateStreamRequest } from '../grpc/generated/api_pb';
import { APIClient } from '.';

const ADDRESS = 'localhost:9292';
const CREDENTIALS = credentials.createInsecure();
const STREAM_NAME = 'test-1';
const SUBJECT = 'test-subject-1';

const connection = new Client(ADDRESS, CREDENTIALS);
connection.waitForReady(10000, () => {
console.log('connection ready!');
const client = new APIClient(ADDRESS, CREDENTIALS, {
channelOverride: connection.getChannel(), // Reuse the working channel for APIClient.
});
const createRequest = new CreateStreamRequest();
createRequest.setName(STREAM_NAME);
createRequest.setSubject(SUBJECT);
client.createStream(createRequest, (err) => {
console.log('stream created! now subscribing...');
const subscribeRequest = new SubscribeRequest();
subscribeRequest.setStream(STREAM_NAME);
const subscription = client.subscribe(subscribeRequest);

subscription.on('error', err => {
console.log('> subscribe error = ', err);
});
subscription.on('status', data => {
console.log('> subscribe on status = ', data);
});
subscription.on('end', () => {
console.log('> subscription ended!');
});
subscription.on('close', () => {
console.log('> subscription closed!');
});

subscription.on('data', data => {
console.log('> subscription data = ', data);
});
});
});

0 comments on commit d516570

Please sign in to comment.