Implementing stratum, keep getting invalid solutions

I'm trying to make a miner, but can't quite figure stratum out - keep getting invalid solution replies.
Here is an example of the exchange:

I've tested the solution's validity with zcashd.

I've read


for reference.

Trying on Flypool, if that matters.

At the moment i'm out of ideas...
Any help please?

Have you tried reversing the endianness of of sha256d hash before comparing it to target? That's one mistake that I made.

Another one had something to do with endianness of nonce2 but if your sol validates against zcashd, that can hardly bd the cause.

The miner works just fine as stand-alone, both on mainnet and testnets, so i don't expect any issues like sha256 endianness. Whatever is wrong, it's in the stratum part.

I tried flipping the endianness of anything suspicious, including nonce_1 they sent, nonce i reply, time i reply, solution and so on.

Figured it out with some help on slack.
I was missing the size part of the solution - you should send it in script encoding, not just as-is.
Here is a more detailed doc that mentioned it: