Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RangeError: offset is not uint #311

Closed
c0desurfer opened this issue Mar 11, 2019 · 2 comments
Closed

RangeError: offset is not uint #311

c0desurfer opened this issue Mar 11, 2019 · 2 comments

Comments

@c0desurfer
Copy link

I am getting the error RangeError: offset is not uint from the example code. Any ideas?

<script>
export default {
  name: "KafkaClient",
  props: {
    msg: String
  }, methods: {
      sendSomething: async function() {
          console.log("SENDING SOMETHING")

          const { Kafka } = require("kafkajs")

          const kafka = new Kafka({
              clientId: "kafka-js-client",
              brokers: ["101.107.52.111:9095"],
          })

          const producer = kafka.producer()

          await producer.connect()
          await producer.send({
              topic: "bro",
              messages: [
                  { value: "Hello from Kafka client!" },
              ],
          })

          await producer.disconnect()

          const consumer = kafka.consumer({ groupId: 'kafka-js-clients' })

          await consumer.connect()
          await consumer.subscribe({ topic: 'bro' })

          await consumer.run({
              eachMessage: async ({ topic, partition, message }) => {
                  console.log({
                      value: message.value.toString(),
                  })
              },
          })

          await consumer.disconnect()
      }
    }
}
</script>
RangeError: offset is not uint
    at checkOffset (index.js?b639:1097)
    at Uint8Array.readUInt32BE (index.js?b639:1157)
    at module.exports (index.js?1a56:22)
    at module.exports (index.js?86bd:21)
    at Client.producer (index.js?0336:56)
    at _callee2$ (KafkaClient.vue?f8d9:31)
    at tryCatch (runtime.js?96cf:62)
    at Generator.invoke [as _invoke] (runtime.js?96cf:288)
    at Generator.prototype.(:8080/anonymous function) [as next] (webpack-internal:///./node_modules/regenerator-runtime/runtime.js:114:21)
    at asyncGeneratorStep (asyncToGenerator.js?3b8d:5)
@Nevon
Copy link
Collaborator

Nevon commented Mar 11, 2019

KafkaJS doesn't support the browser as a runtime environment at the moment. It is intended to be used with NodeJS. #300 fixes the specific issue you ran into, but even using the latest master, you won't be able to connect to Kafka from the browser, as the browser lacks the ability to open raw TCP sockets, which is what's used to communicate with Kafka.

It's something I'm working on, but it won't be available for at least a few weeks.

@Nevon Nevon closed this as completed Mar 11, 2019
@Borewit
Copy link

Borewit commented Aug 11, 2019

This related to feross/buffer#237, maybe caused by webpack/node-libs-browser#93

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants