NH4 - First request test passes but subsequent request test fails

Hi I’m stuck on Serial requests #NH4. When I run my code against the tests I can see the first request having the response. Subsequent requests report the following and I’m not sure if the responses from my end are being received for tests. Here is what the tester tells me.

[tester::#NH4] Running tests for Stage #NH4 (Concurrent Clients - Serial requests)
[tester::#NH4] $ ./your_program.sh /tmp/server.properties
[tester::#NH4] Connecting to broker at: localhost:9092
[your_program] Logs from your program will appear here!
[your_program] test before read
[tester::#NH4] Connection to broker at localhost:9092 successful
[tester::#NH4] Sending request 1 of 3: "ApiVersions" (version: 4) request (Correlation id: 2012015867)
[tester::#NH4] Hexdump of sent "ApiVersions" request: 
[tester::#NH4] Idx  | Hex                                             | ASCII
[tester::#NH4] -----+-------------------------------------------------+-----------------
[tester::#NH4] 0000 | 00 00 00 23 00 12 00 04 77 ec ec fb 00 09 6b 61 | ...#....w.....ka
[tester::#NH4] 0010 | 66 6b 61 2d 63 6c 69 00 0a 6b 61 66 6b 61 2d 63 | fka-cli..kafka-c
[tester::#NH4] 0020 | 6c 69 04 30 2e 31 00                            | li.0.1.
[tester::#NH4] 
[your_program] test number of bytes 39
[tester::#NH4] Hexdump of received "ApiVersions" response: 
[tester::#NH4] Idx  | Hex                                             | ASCII
[tester::#NH4] -----+-------------------------------------------------+-----------------
[tester::#NH4] 0000 | 00 00 00 13 77 ec ec fb 00 00 02 00 12 00 00 00 | ....w...........
[tester::#NH4] 0010 | 04 00 00 00 00 00 00                            | .......
[tester::#NH4] 
[tester::#NH4] [Decoder] - .ResponseHeader
[tester::#NH4] [Decoder]   - .correlation_id (2012015867)
[tester::#NH4] [Decoder] - .ResponseBody
[tester::#NH4] [Decoder]   - .error_code (0)
[tester::#NH4] [Decoder]   - .num_api_keys (1)
[tester::#NH4] [Decoder]   - .ApiKeys[0]
[tester::#NH4] [Decoder]     - .api_key (18)
[tester::#NH4] [Decoder]     - .min_version (0)
[tester::#NH4] [Decoder]     - .max_version (4)
[tester::#NH4] [Decoder]     - .TAG_BUFFER
[tester::#NH4] [Decoder]   - .throttle_time_ms (0)
[tester::#NH4] [Decoder]   - .TAG_BUFFER
[tester::#NH4] ✓ Correlation ID: 2012015867
[tester::#NH4] ✓ Error code: 0 (NO_ERROR)
[tester::#NH4] ✓ API keys array is non-empty
[tester::#NH4] ✓ API version 4 is supported for API_VERSIONS
[tester::#NH4] ✓ Test 1 of 3: Passed
[tester::#NH4] Sending request 2 of 3: "ApiVersions" (version: 4) request (Correlation id: 1521498597)
[your_program] test writeout bytes 25
[your_program] 00000000  00 00 00 13 77 ec ec fb  00 00 02 00 12 00 00 00  |....w...........|
[tester::#NH4] Hexdump of sent "ApiVersions" request: 
[tester::#NH4] Idx  | Hex                                             | ASCII
[tester::#NH4] -----+-------------------------------------------------+-----------------
[tester::#NH4] 0000 | 00 00 00 23 00 12 00 04 5a b0 39 e5 00 09 6b 61 | ...#....Z.9...ka
[tester::#NH4] 0010 | 66 6b 61 2d 63 6c 69 00 0a 6b 61 66 6b 61 2d 63 | fka-cli..kafka-c
[tester::#NH4] 0020 | 6c 69 04 30 2e 31 00                            | li.0.1.
[tester::#NH4] 
[tester::#NH4] Hexdump of received "ApiVersions" response: 
[tester::#NH4] Idx  | Hex                                             | ASCII
[tester::#NH4] -----+-------------------------------------------------+-----------------
[tester::#NH4] 0000 | 00 00 00 00                                     | ....
[tester::#NH4] 
[your_program] 00000010  04 00 00 00 00 00 00 00  00                       |.........|
[tester::#NH4] [Decoder] - .ResponseHeader
[tester::#NH4] Received:
[tester::#NH4] Hex (bytes 0--1)                                | ASCII
[tester::#NH4] ------------------------------------------------+------------------
[tester::#NH4] | 
[tester::#NH4]  ^                                                ^
[tester::#NH4] Error: Expected int32 length to be 4 bytes, got 0 bytes
[tester::#NH4] Context:
[tester::#NH4] - ApiVersions v3
[tester::#NH4]   - Response Header
[tester::#NH4]     - correlation_id
[tester::#NH4]       - INT32
[tester::#NH4] 
[tester::#NH4] Test failed
[tester::#NH4] Terminating program
[tester::#NH4] Program terminated successfully

I have looked at the test code here and its not clear what the problem is from my end because the first test is passing. Thank you for your guidance.

Hey @mzaman07, could you upload your code to GitHub and share the link? It will be much easier to debug if I can run it directly.

Here is the github repo

@mzaman07 The task for this stage is to handle multiple requests over the same connection. It looks like that part isn’t implemented yet.

Hint: you may need a loop inside your handleConn function.

Oh I see I was under the impression that the subsequent requests were using the same tcp connection and would just wait for the subsequent request would come in. This is what created the confusion. I’ll try it out thanks.

1 Like