fetch error since 7.13: "failure: ERROR parsing http: there was no content-length or transfer-encoding"

Hello,

since 7.13, my fetch script returns this error when fetching a webpage: “failure: ERROR parsing http: there was no content-length or transfer-encoding”
This fetch script calls a page from an ethernet relay board in the lan.

The device (ref: https://www.kmtronic.com/lan-ethernet-ip-8-channels-web-relay-board.html):

The routerOS code:

:put [/tool fetch url="http://192.168.1.199/FF0100" as-value output=user]

The routerOS error returned:

failure: ERROR parsing http: there was no content-length or transfer-encoding

This behavior seems to have low visibility on the forums: looking around, I was only able to find one post from un9edsda here:
http://forum.mikrotik.com/t/v7-14beta-testing-is-released/172080/185

It may be that the ethernet relay PCB doesn’t revert a specific field, and I have no control over this, but until routerOS 7.13, this was not an issue: fetch seemed to be more flexible at accommodating this and returning the fetched content.
I confirm that freshly released 7.13.4 still display this error message.

What can be done to provide fetch the same level of flexibility it had until 7.12.1?

Thank you

Issue should be fixed in latest 7.14 beta versions

fantastic news, many thanks Normis!

Hi Normis,

I’m re-opening this:
I just updated to 7.14, but the error persists, although the error message is slightly different

failure: there was no content-length or transfer-encoding

Is there something I can provide you with in order to replicate?

Thanks

i’m with ROS 14.3 stable branch and this error persists.

I have a full range of scripts that push data to a prometheus pushgateway to audit quality of links and all of them just stop working on update.

"failure: there was no content-length or transfer-encoding"

Is there any solution to this?

Many thanks.

Also… i just realize that a sync script for an HA cluster just broke completly because of this.

This is so bad…

Hi @brunolabozzetta! Since this is a user forum, it’s probably better if you contact MikroTik directly via email at “support@mikrotik.com” or open a support ticket using the link “https://help.mikrotik.com/servicedesk/servicedesk.” //BR, Larsa.

This error is already identified and was supposed to be fixed in 7.14
But it’s still ongoing.
Ideally MikroTik can provide an ETA on resolution

MikroTik RouterOS 7.16.1

/tool fetch mode=http url=http://192.168.0.1/ output=user-with-headers
status: failed

failure: there was no content-length or transfer-encoding

So the issue is still being there

Same here, v7.16.2 arm :frowning:

is there any workaround? I’ve tried every possible setting without luck.

Strangely, when I run the same /tool/fetch from a terminal, it works fine. It only doesn’t work from the script

Hi, I have thoroughly investigated this error, and it is due to an incorrect response from the server.

The header contains the Content-Type field but does NOT contain the Content-Length field, and this generates the error.

If the server responds with the Content-Type field, it MUST also enter the Content-Length field.
The combination are:
Content-Type and Content-Length
OR
Transfer-Encoding and Content-Length

It’s a problem of the server side that is not compliant with HTTP 1.1.

Header with error (don’t works with fetch)
header error.png
Header correct with Content-Type (works with fetch)
header ok.png
Header correct with Transfer-Encoding (works with fetch)
header ok transfer encoding.png
Marco

Same result as: http://forum.mikrotik.com/t/fetch-error-since-7-13-failure-error-parsing-http-there-was-no-content-length-or-transfer-encoding/173446/4

Hi, I found a workaround executing an asyncronous fetch request inside the script by execute function:

here the example of my script

[[execute "tool fetch url=\"http://server-ip:port/leds.cgi?led=0\" "]]
[[execute "tool fetch url=\"http://server-ip:port/leds.cgi?led=1\" "]]

I wrote to MikroTik support to describe in details this questions.
I hope that this solution fix your problem.

Marco

I confirm this works fine, no idea what it does different in the background, but it is a perfect workaround.

Thank you very much!

BTW: I have also contacted Mikrotik support, they were very helpful and fixed it in the next release.
I understand it it most likely a broken server, but it seems there are too many of them to ignore it :frowning: like self signed certs :slight_smile:


Thank you Marco,

But unfortunately, this still doesn’t work for me:

  • the http server does register the fetch and flip the switch accordingly
  • but on Mikrotik side, I still can’t parse the response, instead the same error message is thrown
    The same behavior occured before this asynchronous scripting unfortunately.

Both codes return the same error message - running RouterOS version 7.16.2:

:put [[execute "tool fetch url=\"http://192.168.1.199/FF0100\" as-value output=user-with-headers"]]



:put [/tool fetch url="http://192.168.1.199/FF0100" as-value output=user-with-headers]

The error message:

failure: there was no content-length or transfer-encoding




Hi timemaster,

do you mean that we can expect a fix in the future … or is the fix already published in a previous release?

It was a nightly build of the 7.18 version. I don’t know what the next stable release is, but I expect the one that follows the current nightly build.

Thanks for the clarification.
Would you happen to have a link to the changelog to expectat in 7.18?
I can’t find much as currently 7.17 is in release candidate, and nothing on 7.18 is mentionned here: https://mikrotik.com/download/changelogs

Nightly builds are alpha/developers’ versions and nothing is guaranteed to enter to beta of same version. So there’s never any changelog for nightly builds. We’ve seen stuff removed from beta versions (rarely, but it did happen) so I’d guess that would happen even more often with alpha versions.

Nightly builds are sometimes (not often) offered to users which reported particular problem and devs managed to replicate and fix the problem … and offering nightly build with fix is some kind of courtesy to those users. Since same nightly builds contain other development code, they may break something else, which means that even user who receives such build, should use it with extreme care. Consider all the problem reports with beta/rc versions … and assume that alpha/nightly versions are almost certainly worse.

Got it, makes sense,

Where do you got your source then that 7.18 would feature a fix for this issue?

See my second paragraph (add while you were posting your latest post).