You are not logged in.
Hi there.
I'm using nc to test a server component I'm working on. The content being sent/received is ASCII only. Using the command line bellow I get the data on the server but nc is not printing the response it's receiving.
cat msg.poll.init.txt | nc -q 2 localhost 1111I did a lot of googling for this issue and all the answers I could find were about the -q parameter, that is, nc exiting as soon as it sends the content, not waiting for an answer. I also tried ncat, from nman package, same result, no output. What gives?
I'm at a loss, need help ![]()
Thanks in advance,
Mircea.
Last edited by mdcclxv (2023-06-02 22:45:33)
Offline
printf "GET / HTTP/1.0\r\n\r\n" | nc example.com 80Should get you a 404 (just like when trying to open example.com in a browser) - if that works, wireshark the connection, most likely the server simply doesn't send anything.
Offline
... all the answers I could find were about the -q parameter, that is, nc exiting as soon as it sends the content, not waiting for an answer.
And ... why does that answer not satisfy you? Do you get the same results without the -q flag?
Last edited by Trilby (2023-05-30 16:25:33)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
printf "GET / HTTP/1.0\r\n\r\n" | nc example.com 80Should get you a 404 (just like when trying to open example.com in a browser) - if that works, wireshark the connection, most likely the server simply doesn't send anything.
Now this is mind boggling. It works, just as expected. My server component does send back content, because I'm also testing it in conjunction with a remote client system, which does receive the content. It's just that it would be way easier to debug my server component with a local client.
Offline
Sends back data *how*?
If it doesn't send a response but talks to the client w/ a new connection, you'll have to hasve nc listen on that port (w/ a second instance)
Offline
Sends back data *how*?
If it doesn't send a response but talks to the client w/ a new connection, you'll have to hasve nc listen on that port (w/ a second instance)
No no, my component is the server. The client connects, sends a message and receives a response. Those would be nc and the other remote system. That remote system does receive a response from my component, that's a fact. Also, I can see on the server what nc sends and I can also see the response being sent back to nc. No difference on the server side behavior between nc connection and the remote client connection.
Doesn't add up ![]()
Offline
And ... why does
that answer not satisfyit not add up to you? Do you get the same results without the -q flag?
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Trilby wrote:And ... why does
that answer not satisfyit not add up to you? Do you get the same results without the -q flag?
Because Seth's test works as expected, but using the same nc command line on my server it doesn't while there IS a message being sent back to nc. Tried both with and without -q. Same issue, no output.
Maybe I'm getting paranoid here, but I think the messages has to meet certain conditions for nc to spit it out. I tried a double CRLF ending, no luck.
Offline
Cut out the terminal
cat msg.poll.init.txt | nc localhost 1111 > /tmp/result.txtCan you share the wireshark record and/or response data (ie. is the server sending any sensitive stuff)?
Last edited by seth (2023-05-30 19:59:19)
Offline
Sorry for the late response, I was under a lot of pressure to get things done.
But, in the process, I discovered that the underlying server code that was actually sending the message is transparently validating the client by requesting a signature. The request itself was the ENQ control character, which is not printable, so the terminal running nc was not showing anything. But the actual problem was that the server code was not logging anywhere the validation timeout, which would have raised some flags for me. Now that's healthy coding!
I've commented the validation code while debugging and, lo and behold, I got output in nc. And I've also added the missing log lines ![]()
Had I tried Seth's last suggestion I would've seen the ENQ in the result.txt file. But I didn't because of the hurry ![]()
So, once again, thank you guys so much for your time and effort. You rock!
Last edited by mdcclxv (2023-06-02 22:46:16)
Offline