You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the latest code from master, I'm creating an event from Kafka which is coming into my app as: body: "{"specversion":"1.0","id":"3","type":"type","source":"123"}"
const express = require('express');
const app = express();
const { HTTPReceiver, CloudEvent } = require('cloudevents-sdk');
const receiver = new HTTPReceiver();
app.use((req, res, next) => {
let data = "";
//req.setEncoding("utf8");
req.on("data", function(chunk) {
data += chunk;
});
req.on("end", function() {
req.body = data;
next();
});
});
app.post('/', (req, res) => {
console.log('Version 1.20');
console.log('body:',JSON.stringify(req.body))
console.log('headers:',JSON.stringify(req.headers))
try {
let myevent = receiver.accept(req.headers,req.body);
console.log(JSON.stringify(myevent))
res.status(201).send("Event Accepted");
} catch(err) {
// TODO deal with errors
console.error(err);
res.status(415)
.header("Content-Type", "application/json")
.send(JSON.stringify(err));
}
});
const port = process.env.PORT || 8080;
app.listen(port, () => {
console.log('Hello world listening on port', port);
});
I receive the following error:
TypeError: Cannot read property 'parse' of undefined
at BinaryHTTPReceiver.parse (/usr/src/app/node_modules/cloudevents-sdk/lib/bindings/http/receiver_binary.js:115:9)
at Receiver.parse (/usr/src/app/node_modules/cloudevents-sdk/lib/bindings/http/receiver_binary_1.js:111:24)
at HTTPReceiver.accept (/usr/src/app/node_modules/cloudevents-sdk/lib/bindings/http/http_receiver.js:26:40)
at /usr/src/app/index.js:26:28
at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5)
at next (/usr/src/app/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/usr/src/app/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5)
at /usr/src/app/node_modules/express/lib/router/index.js:281:22
at Function.process_params (/usr/src/app/node_modules/express/lib/router/index.js:335:12)
The text was updated successfully, but these errors were encountered:
Using the latest code from master, I'm creating an event from Kafka which is coming into my app as:
body: "{"specversion":"1.0","id":"3","type":"type","source":"123"}"
headers: {"host":"event-display.kafka.svc.cluster.local","user-agent":"Go-http-client/1.1","content-length":"59","accept-encoding":"gzip","ce-id":"partition:1/offset:23","ce-source":"/apis/v1/namespaces/kafka/kafkasources/kafka-source#knative-demo-topic","ce-specversion":"1.0","ce-subject":"partition:1#23","ce-time":"2020-05-07T14:16:30.245Z","ce-type":"dev.knative.kafka.event","forwarded":"for=10.131.0.72;proto=http","k-proxy-request":"activator","kourier-random-header":"558c917a-906d-11ea-96ab-0a580a830047","traceparent":"00-73df58d7c1383e17dabe515dfd68d05a-b00799e628f49cbe-00","x-envoy-expected-rq-timeout-ms":"600000","x-forwarded-for":"10.131.0.72, 10.128.2.99","x-forwarded-proto":"http","x-request-id":"d3649c1b-a968-40bf-a9da-3e853abc0c8b"}
The code I'm using is as follows:
I receive the following error:
The text was updated successfully, but these errors were encountered: