dapr / dapr/js-sdk

PubSub with large message does not trigger subscriber

Open
#562 7 comments 1 reaction 1 assignee Claimed by @shubham1172 View on GitHub
area/pubsub
Dominant language
JavaScript
Stars
217
Forks
104
PR merge metrics
No merged PRs in 30d

Description

## Expected Behavior

Publishing a large message that, for instance, has a base64 image string should trigger the subscriber.

Publisher
```js
import { DaprClient, CommunicationProtocolEnum } from '@dapr/dapr';
import * as image from './image.js'

const client = new DaprClient({
communicationProtocol: CommunicationProtocolEnum.GRPC,
maxBodySizeMb: 10,
});

console.log("Publishing...")
setInterval(async () => {
await client.pubsub.publish("pubsub", "test", {
payload: image.data.image, //base64 image string

}, {
metadata:{
ttlInSeconds:"1"
}
});
console.log("published")
}, 3000);
```

Subscriber:
```js
import { DaprServer, CommunicationProtocolEnum, DaprPubSubStatusEnum } from '@dapr/dapr';
const server = new DaprServer({
communicationProtocol: CommunicationProtocolEnum.GRPC,
clientOptions: {
communicationProtocol: CommunicationProtocolEnum.GRPC
}
});

const configs = await server.client.configuration.get("configuration", ["key"])

server.pubsub.subscribe("pubsub", "test", async (data, headers) => {
console.log("Subscriber received: " + JSON.stringify(data));
return DaprPubSubStatusEnum.SUCCESS;
}
);

await server.start();
```

command:
```js
"scripts": {
"client": "dapr run --app-id checkout --dapr-http-port 3502 --app-protocol grpc --resources-path .dapr/components/ -- node client.js",
"server": "dapr run --app-id order-processing --app-port 5002 --dapr-http-port 3501 --app-protocol grpc --resources-path .dapr/components/ -- node server.js"
},
```

Redis PubSub Component Definition
```yaml
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: pubsub
spec:
type: pubsub.redis
version: v1
metadata:
- name: redisHost
value: localhost:6379
- name: redisPassword
value: ""
```

## Actual Behavior

Although the message get published to Redis stream the subscriber does not get triggered. In this test we are using a base64 image that is around 150kb.

If I just set the `payload` to `payload: ""` the subscriber gets triggered.

## Steps to Reproduce the Problem

- Convert an image to a base64 string and pass the string into the `payload` on the publisher.
- Execute both the client and the server npm scripts.
- Published messages should be on the redis stream named `test`.
- Subscriber _is not triggered_.
- Stop both client and server.
- Update the `payload` to be empty `payload:""`
- Execute both the client and the server npm scripts.
- Published messages should be on the redis stream named `test`.
- Subscriber _is triggered_.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.