nc shows partial output

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I'm using busybox v1.28.1 on an embedded device (armv7l). I want to use nc to listen to TCP connections made by a javascript application (QML) on the same machine.



Here an example of the request:



function post(url, data) 
var xhr = new XMLHttpRequest();
var params = data;

var timer = Qt.createQmlObject("import QtQuick 1.1; Timer interval: 50; repeat: false; running: true;", root, "TimerTimeout");

timer.triggered.connect(function()
xhr.abort();
);

xhr.onreadystatechange = function()
if (xhr.readyState === XMLHttpRequest.DONE)
timer.running = false;
timer.destroy();

;

xhr.open("POST", url, true);
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.setRequestHeader("Content-length", params.length);
xhr.setRequestHeader("Connection", "close");
xhr.send(params);


// ...

post("http://127.0.0.1:55764", "Hello world");


From the console I run this command:



./busybox-armv7l nc -klv -p 55764


it should listen for incoming connection on port 55764, and should stay listening for another connection after its current connection is completed.



But this is the, werid, behavior I notice:




  1. start server:



    ./busybox-armv7l nc -klv -p 55764
    listening on [::]:55764 ...




  2. send the first packet:



    connect to [::ffff:127.0.0.1]:55764 from localhost.localdomain:34325 ([::ffff:127.0.0.1]:34325)



3.send another packet:



POST / HTTP/1.1
Content-Type: application/x-www-form-urlencoded;charset=UTF-8
Content-Length: 5
Connection: Keep-Alive
Accept-Encoding: gzip
Accept-Language: en,*
User-Agent: Mozilla/5.0
Host: 127.0.0.1:55764

Hello world


  1. now if I send other packets no more output is shown

Why?



EDIT



I changed the code like this:



function post(url, data) 
var xhr = new XMLHttpRequest();
var params = data;

var timer = Qt.createQmlObject("import QtQuick 1.1; Timer interval: 50; repeat: false; running: true;", root, "TimerTimeout");

timer.triggered.connect(function()
xhr.abort();
);

xhr.onreadystatechange = function()
if (xhr.readyState === XMLHttpRequest.DONE)
timer.running = false;
timer.destroy();
//console.log(xhr.responseText);

;

xhr.open("POST", url, true);
xhr.setRequestHeader("Content-length", params.length);
xhr.send(params);



and the script:



#!/bin/bash
while true; do
echo -e "HTTP/1.1 200 OKnn" | ./busybox-armv7l nc -lv -p 55764 -w 1
done


and it seems to work.
Do you see other evidence of errors?










share|improve this question



















  • 1




    I see a lot of odd things here. Your attempt to send Connection: close didn't work; Connection: Keep-Alive was received instead. You claimed you were sending x-www-form-urlencoded data but you didn't urlencode the space. The Content-Length is wrong. You're making no attempt to reply to the HTTP request.
    – Wumpus Q. Wumbley
    Nov 18 at 2:34











  • Would you please help me to understand the right syntax? I found several examples like this. And I'm not sure how to send a response with nc.
    – Mark
    Nov 18 at 5:14














up vote
0
down vote

favorite












I'm using busybox v1.28.1 on an embedded device (armv7l). I want to use nc to listen to TCP connections made by a javascript application (QML) on the same machine.



Here an example of the request:



function post(url, data) 
var xhr = new XMLHttpRequest();
var params = data;

var timer = Qt.createQmlObject("import QtQuick 1.1; Timer interval: 50; repeat: false; running: true;", root, "TimerTimeout");

timer.triggered.connect(function()
xhr.abort();
);

xhr.onreadystatechange = function()
if (xhr.readyState === XMLHttpRequest.DONE)
timer.running = false;
timer.destroy();

;

xhr.open("POST", url, true);
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.setRequestHeader("Content-length", params.length);
xhr.setRequestHeader("Connection", "close");
xhr.send(params);


// ...

post("http://127.0.0.1:55764", "Hello world");


From the console I run this command:



./busybox-armv7l nc -klv -p 55764


it should listen for incoming connection on port 55764, and should stay listening for another connection after its current connection is completed.



But this is the, werid, behavior I notice:




  1. start server:



    ./busybox-armv7l nc -klv -p 55764
    listening on [::]:55764 ...




  2. send the first packet:



    connect to [::ffff:127.0.0.1]:55764 from localhost.localdomain:34325 ([::ffff:127.0.0.1]:34325)



3.send another packet:



POST / HTTP/1.1
Content-Type: application/x-www-form-urlencoded;charset=UTF-8
Content-Length: 5
Connection: Keep-Alive
Accept-Encoding: gzip
Accept-Language: en,*
User-Agent: Mozilla/5.0
Host: 127.0.0.1:55764

Hello world


  1. now if I send other packets no more output is shown

Why?



EDIT



I changed the code like this:



function post(url, data) 
var xhr = new XMLHttpRequest();
var params = data;

var timer = Qt.createQmlObject("import QtQuick 1.1; Timer interval: 50; repeat: false; running: true;", root, "TimerTimeout");

timer.triggered.connect(function()
xhr.abort();
);

xhr.onreadystatechange = function()
if (xhr.readyState === XMLHttpRequest.DONE)
timer.running = false;
timer.destroy();
//console.log(xhr.responseText);

;

xhr.open("POST", url, true);
xhr.setRequestHeader("Content-length", params.length);
xhr.send(params);



and the script:



#!/bin/bash
while true; do
echo -e "HTTP/1.1 200 OKnn" | ./busybox-armv7l nc -lv -p 55764 -w 1
done


and it seems to work.
Do you see other evidence of errors?










share|improve this question



















  • 1




    I see a lot of odd things here. Your attempt to send Connection: close didn't work; Connection: Keep-Alive was received instead. You claimed you were sending x-www-form-urlencoded data but you didn't urlencode the space. The Content-Length is wrong. You're making no attempt to reply to the HTTP request.
    – Wumpus Q. Wumbley
    Nov 18 at 2:34











  • Would you please help me to understand the right syntax? I found several examples like this. And I'm not sure how to send a response with nc.
    – Mark
    Nov 18 at 5:14












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm using busybox v1.28.1 on an embedded device (armv7l). I want to use nc to listen to TCP connections made by a javascript application (QML) on the same machine.



Here an example of the request:



function post(url, data) 
var xhr = new XMLHttpRequest();
var params = data;

var timer = Qt.createQmlObject("import QtQuick 1.1; Timer interval: 50; repeat: false; running: true;", root, "TimerTimeout");

timer.triggered.connect(function()
xhr.abort();
);

xhr.onreadystatechange = function()
if (xhr.readyState === XMLHttpRequest.DONE)
timer.running = false;
timer.destroy();

;

xhr.open("POST", url, true);
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.setRequestHeader("Content-length", params.length);
xhr.setRequestHeader("Connection", "close");
xhr.send(params);


// ...

post("http://127.0.0.1:55764", "Hello world");


From the console I run this command:



./busybox-armv7l nc -klv -p 55764


it should listen for incoming connection on port 55764, and should stay listening for another connection after its current connection is completed.



But this is the, werid, behavior I notice:




  1. start server:



    ./busybox-armv7l nc -klv -p 55764
    listening on [::]:55764 ...




  2. send the first packet:



    connect to [::ffff:127.0.0.1]:55764 from localhost.localdomain:34325 ([::ffff:127.0.0.1]:34325)



3.send another packet:



POST / HTTP/1.1
Content-Type: application/x-www-form-urlencoded;charset=UTF-8
Content-Length: 5
Connection: Keep-Alive
Accept-Encoding: gzip
Accept-Language: en,*
User-Agent: Mozilla/5.0
Host: 127.0.0.1:55764

Hello world


  1. now if I send other packets no more output is shown

Why?



EDIT



I changed the code like this:



function post(url, data) 
var xhr = new XMLHttpRequest();
var params = data;

var timer = Qt.createQmlObject("import QtQuick 1.1; Timer interval: 50; repeat: false; running: true;", root, "TimerTimeout");

timer.triggered.connect(function()
xhr.abort();
);

xhr.onreadystatechange = function()
if (xhr.readyState === XMLHttpRequest.DONE)
timer.running = false;
timer.destroy();
//console.log(xhr.responseText);

;

xhr.open("POST", url, true);
xhr.setRequestHeader("Content-length", params.length);
xhr.send(params);



and the script:



#!/bin/bash
while true; do
echo -e "HTTP/1.1 200 OKnn" | ./busybox-armv7l nc -lv -p 55764 -w 1
done


and it seems to work.
Do you see other evidence of errors?










share|improve this question















I'm using busybox v1.28.1 on an embedded device (armv7l). I want to use nc to listen to TCP connections made by a javascript application (QML) on the same machine.



Here an example of the request:



function post(url, data) 
var xhr = new XMLHttpRequest();
var params = data;

var timer = Qt.createQmlObject("import QtQuick 1.1; Timer interval: 50; repeat: false; running: true;", root, "TimerTimeout");

timer.triggered.connect(function()
xhr.abort();
);

xhr.onreadystatechange = function()
if (xhr.readyState === XMLHttpRequest.DONE)
timer.running = false;
timer.destroy();

;

xhr.open("POST", url, true);
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.setRequestHeader("Content-length", params.length);
xhr.setRequestHeader("Connection", "close");
xhr.send(params);


// ...

post("http://127.0.0.1:55764", "Hello world");


From the console I run this command:



./busybox-armv7l nc -klv -p 55764


it should listen for incoming connection on port 55764, and should stay listening for another connection after its current connection is completed.



But this is the, werid, behavior I notice:




  1. start server:



    ./busybox-armv7l nc -klv -p 55764
    listening on [::]:55764 ...




  2. send the first packet:



    connect to [::ffff:127.0.0.1]:55764 from localhost.localdomain:34325 ([::ffff:127.0.0.1]:34325)



3.send another packet:



POST / HTTP/1.1
Content-Type: application/x-www-form-urlencoded;charset=UTF-8
Content-Length: 5
Connection: Keep-Alive
Accept-Encoding: gzip
Accept-Language: en,*
User-Agent: Mozilla/5.0
Host: 127.0.0.1:55764

Hello world


  1. now if I send other packets no more output is shown

Why?



EDIT



I changed the code like this:



function post(url, data) 
var xhr = new XMLHttpRequest();
var params = data;

var timer = Qt.createQmlObject("import QtQuick 1.1; Timer interval: 50; repeat: false; running: true;", root, "TimerTimeout");

timer.triggered.connect(function()
xhr.abort();
);

xhr.onreadystatechange = function()
if (xhr.readyState === XMLHttpRequest.DONE)
timer.running = false;
timer.destroy();
//console.log(xhr.responseText);

;

xhr.open("POST", url, true);
xhr.setRequestHeader("Content-length", params.length);
xhr.send(params);



and the script:



#!/bin/bash
while true; do
echo -e "HTTP/1.1 200 OKnn" | ./busybox-armv7l nc -lv -p 55764 -w 1
done


and it seems to work.
Do you see other evidence of errors?







tcp http javascript nc






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 days ago

























asked Nov 17 at 21:29









Mark

1389




1389







  • 1




    I see a lot of odd things here. Your attempt to send Connection: close didn't work; Connection: Keep-Alive was received instead. You claimed you were sending x-www-form-urlencoded data but you didn't urlencode the space. The Content-Length is wrong. You're making no attempt to reply to the HTTP request.
    – Wumpus Q. Wumbley
    Nov 18 at 2:34











  • Would you please help me to understand the right syntax? I found several examples like this. And I'm not sure how to send a response with nc.
    – Mark
    Nov 18 at 5:14












  • 1




    I see a lot of odd things here. Your attempt to send Connection: close didn't work; Connection: Keep-Alive was received instead. You claimed you were sending x-www-form-urlencoded data but you didn't urlencode the space. The Content-Length is wrong. You're making no attempt to reply to the HTTP request.
    – Wumpus Q. Wumbley
    Nov 18 at 2:34











  • Would you please help me to understand the right syntax? I found several examples like this. And I'm not sure how to send a response with nc.
    – Mark
    Nov 18 at 5:14







1




1




I see a lot of odd things here. Your attempt to send Connection: close didn't work; Connection: Keep-Alive was received instead. You claimed you were sending x-www-form-urlencoded data but you didn't urlencode the space. The Content-Length is wrong. You're making no attempt to reply to the HTTP request.
– Wumpus Q. Wumbley
Nov 18 at 2:34





I see a lot of odd things here. Your attempt to send Connection: close didn't work; Connection: Keep-Alive was received instead. You claimed you were sending x-www-form-urlencoded data but you didn't urlencode the space. The Content-Length is wrong. You're making no attempt to reply to the HTTP request.
– Wumpus Q. Wumbley
Nov 18 at 2:34













Would you please help me to understand the right syntax? I found several examples like this. And I'm not sure how to send a response with nc.
– Mark
Nov 18 at 5:14




Would you please help me to understand the right syntax? I found several examples like this. And I'm not sure how to send a response with nc.
– Mark
Nov 18 at 5:14















active

oldest

votes











Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f482403%2fnc-shows-partial-output%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f482403%2fnc-shows-partial-output%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown






Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?