Stack on question #wa6

I’m stuck on Stage #wa6.

I think my solution is correct, but I cannot pass the test. I’ve tested it via netcat also.
It would be really helpful to enhance the test by showing the actual value being passed by our program and makes the test fail.

Here are my logs:

[tester::#WA6] Running tests for Stage #WA6 (Parse Correlation ID)
[tester::#WA6] $ ./your_program.sh
[tester::#WA6] Connecting to broker at: localhost:9092
[your_program] Logs from your program will appear here!
[tester::#WA6] Connection to broker at localhost:9092 successful
[tester::#WA6] Sending "ApiVersions" (version: 4) request (Correlation id: 36224004)
[tester::#WA6] Hexdump of sent "ApiVersions" request: 
[tester::#WA6] Idx  | Hex                                             | ASCII
[tester::#WA6] -----+-------------------------------------------------+-----------------
[tester::#WA6] 0000 | 00 00 00 23 00 12 00 04 02 28 bc 04 00 09 6b 61 | ...#.....(....ka
[tester::#WA6] 0010 | 66 6b 61 2d 63 6c 69 00 0a 6b 61 66 6b 61 2d 63 | fka-cli..kafka-c
[tester::#WA6] 0020 | 6c 69 04 30 2e 31 00                            | li.0.1.
[tester::#WA6] 
[your_program] accepted new connection
[your_program] req = [0, 0, 0, 35, 0, 18, 0, 4, 2, 40, 188, 4]
[your_program] v = [0, 0, 0, 8, 2, 40, 188, 4]
[your_program] NUM  = 36224004
[tester::#WA6] error reading from connection: read tcp 127.0.0.1:33922->127.0.0.1:9092: read: connection reset by peer
[tester::#WA6] Test failed

v is a vector written to the TcpStream (my solution is in Rust). And the last 4 bytes are indeed the Correlation ID.

@DimitrisCharisis Could you please put your code on GitHub so that I can take a look at it for you?

Hi @andy1li, here is the gist:

Any idea?
Again, I think it would be helpful to print the actual values being compared.

Thanks.

Sorry for the delayed response.

The cause for connection reset by peer is because the connection wasn’t flushed and properly closed.

The solution is to add these two lines of code after write:

            Ok(mut _stream) => {
                ...
                _stream.write(&v).expect("Write to TcpStream Failed");

                // Flush the _stream to ensure data is sent
+               _stream.flush().expect("Flush failed");

                // Shutdown the write side to indicate we're done sending
+               _stream.shutdown(Shutdown::Write).expect("Shutdown failed");

@DimitrisCharisis Could you give this a try, and please let me know how it goes?

Yes @andy1li that was the problem!

1 Like

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