Kafka : Looks like your program has terminated. A Kafka server is expected to be a long-running process

I’m stuck on Stage Send Correlation ID #nv3

I’ve tried the other solution provided adding a new line, but that did not work either.

Here are my logs:

remote: [tester::#NV3] Running tests for Stage #NV3 (Send Correlation ID)
remote: [tester::#NV3] $ ./your_program.sh /tmp/server.properties
remote: [tester::#NV3] [Serializer] Writing log files to: /tmp/kraft-combined-logs
remote: [tester::#NV3] [Serializer]   - Wrote file to: /tmp/server.properties
remote: [tester::#NV3] [Serializer]   - Wrote file to: /tmp/kraft-combined-logs/meta.properties
remote: [tester::#NV3] [Serializer]   - Wrote file to: /tmp/kraft-combined-logs/.kafka_cleanshutdown
remote: [tester::#NV3] [Serializer]   - Wrote file to: /tmp/kraft-combined-logs/bar-0/partition.metadata
remote: [tester::#NV3] [Serializer]   - Wrote file to: /tmp/kraft-combined-logs/paz-0/partition.metadata
remote: [tester::#NV3] [Serializer]   - Wrote file to: /tmp/kraft-combined-logs/qux-0/partition.metadata
remote: [tester::#NV3] [Serializer]   - Wrote file to: /tmp/kraft-combined-logs/qux-1/partition.metadata
remote: [tester::#NV3] [Serializer]   - Wrote file to: /tmp/kraft-combined-logs/__cluster_metadata-0/partition.metadata
remote: [tester::#NV3] [Serializer]   - Wrote file to: /tmp/kraft-combined-logs/bar-0/00000000000000000000.log
remote: [tester::#NV3] [Serializer]   - Wrote file to: /tmp/kraft-combined-logs/paz-0/00000000000000000000.log
remote: [tester::#NV3] [Serializer]   - Wrote file to: /tmp/kraft-combined-logs/qux-0/00000000000000000000.log
remote: [tester::#NV3] [Serializer]   - Wrote file to: /tmp/kraft-combined-logs/qux-1/00000000000000000000.log
remote: [tester::#NV3] [Serializer]   - Wrote file to: /tmp/kraft-combined-logs/__cluster_metadata-0/00000000000000000000.log
remote: [tester::#NV3] [Serializer] Finished writing log files to: /tmp/kraft-combined-logs
remote: [tester::#NV3] Connecting to broker at: localhost:9092
remote: [tester::#NV3] Looks like your program has terminated. A Kafka server is expected to be a long-running process.
remote: [tester::#NV3] Test failed
remote: [tester::#NV3] Terminating program
remote: [tester::#NV3] Program terminated successfully

And here’s a snippet of my code:

import socket  # noqa: F401


def main():
    print("test printing")

    def create_message(idw):
        id_bytes = idw.to_bytes(4, byteorder="big")
        return len(id_bytes).to_bytes(4, byteorder="big") + id_bytes

    def handle_client(client):
        client.recv(1024)
        client.sendall(create_message(9))
        client.close()

    server = socket.create_server(("localhost", 9092), reuse_port=True)
    while True:
        client, addr = server.accept()
        handle_client(client)


@swamyym Could you upload your code to GitHub and share a link here? It will be much easier to debug if I can run your code.

Hey @swamyym your logic is alright but try to make these 2 changes

  1. The test expects idw of 7 to be hardcoded and you are passing 9.
  2. You need to call the main function, that is why your program is getting terminated.
2 Likes

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.