Issue with HttpRequest stream upload or API usage error? #1803
-
Problem DescriptionCan't seem to post audio stream to server using i2s as input and AudioTool's I have based my code on this example: https://github.com/pschatzmann/arduino-audio-tools/blob/main/examples/examples-communication/http-client/streams-http_post/streams-http_post.ino and the above example doesn't seem to work for me either. The server is made in node with express and is as basic as can be:
The minimal arduino sketch is included in the dedicated form field, but I get the same results from the example quoted from this repository. In both cases the Serial output of the ESP32 says:
and the server displays:
While I am expecting it to emit 'data' events as it receives the stream. For some reason that I do not understand the connection gets closed immediately. Am I missing something obvious here? What is the server expected to reply? Device Descriptionesp32dev Sketch#include "AudioTools.h"
#include "AudioTools/AudioLibs/I2SCodecStream.h"
WiFiClient client;
HttpRequest http(client);
const AudioInfo info(44100, 1, 16);
Url target;
I2SCodecStream audioStream(AudioKitEs8388V2);
StreamCopy copier(client, audioStream);
void setup() {
Serial.begin(115200);
AudioLogger::instance().begin(Serial, AudioLogger::Debug);
WiFi.mode(WIFI_STA);
WiFi.begin("***", "***");
while (WiFi.status() != WL_CONNECTED) {
Serial.print('.');
delay(1000);
}
Serial.println();
Serial.println(WiFi.localIP());
auto audioConfig = audioStream.defaultConfig(RX_MODE);
audioConfig.copyFrom(info);
audioStream.begin(audioConfig);
// this doesn't seem to change anything
// http.addRequestHeader("Transfer-Encoding", "chunked");
Url url("http://192.168.1.1:6556/listen");
if (!http.processBegin(POST, url, "audio/pcm")){
Serial.println("post failed");
stop();
}
}
void loop() {
if (copier.copy() == 0) {
http.processEnd();
}
}
|
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 9 replies
-
I think your server expects chunked data but you don't provide it in this format! |
Beta Was this translation helpful? Give feedback.
-
As far as I know that's how node handles requests which do not have a
content-length header specified.
Do you have an example of server you're using for your tests? I couldn't
find one.
…On Mon, Nov 4, 2024, 15:29 Phil Schatzmann ***@***.***> wrote:
Closed #1773
<#1773> as
completed.
—
Reply to this email directly, view it on GitHub
<#1773 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AALESE7C6VHBBZH2352NPXDZ66AF7AVCNFSM6AAAAABREMARHSVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJVGEYDIOJTHA4DOOI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
.com>
|
Beta Was this translation helpful? Give feedback.
-
@djfm i am working on the same problem.
|
Beta Was this translation helpful? Give feedback.
-
But isn't this just a simple chuned post ? |
Beta Was this translation helpful? Give feedback.
-
i have added more debug info to the server.js
and if i stream a file from the client.js i get on the server.js this output
if i run the streams-http_post.ino in get on the server.js this
|
Beta Was this translation helpful? Give feedback.
-
If you need chuned data, you will need to activate it in my API. If I remember right you would do this by adding the transfer-encoding chunked to the request header, e.g like this:
When adding this, all logic is in place for writing chunked data. |
Beta Was this translation helpful? Give feedback.
-
Yes the stream approach is really nice. I actually stopped using your
libraries when I discovered that it was not possible to apply the same
logic for upload as for download (and because the quality of the recorded
audio was really bad, but that one might have been my fault).
…On Wed, Nov 20, 2024, 14:55 Phil Schatzmann ***@***.***> wrote:
This is currently implemented in HttpRequest write. The only issue that I
see is that this is not a subclass of print, so it cant be used as copy
target. But this is easy to change!
—
Reply to this email directly, view it on GitHub
<#1803 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AALESE62BUTAKGDSA6XK3MT2BSIFDAVCNFSM6AAAAABSEKXMT2VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTCMZSGMYDMOI>
.
You are receiving this because you were mentioned.Message ID:
<pschatzmann/arduino-audio-tools/repo-discussions/1803/comments/11323069@
github.com>
|
Beta Was this translation helpful? Give feedback.
I committed a correction: a test with a python server and this sketch with the TRANSFER_ENCODING uncommented is working properly now!