I'm trying to write a stratum client for a cryptocurrency mining application. The mining application connects to a stratum server to receive new work to mine on and submit solutions. 

The stratum protocol is a simple TCP based line protocol with JSON payload. Documentation here:

I've chosen to use boost::asio, as boost is already heavily used in the fork of the project I'm building the miner for. But I'm having difficulties to understand why my current implementation doesn't work.

The basic flow is as follows:
1. connect to the server. this works
2. send subscribe method. this also works
3. authorize worker(s). doesn't work.
4. stratum server should start pushing new work periodically. doesn't work.
5. submit solution when found. not implemented yet.

Without authorization, the server should still start pushing work. So I've skipped step 3 for now.

The source code as I have it now is available here: 

The output I get from this is as follows:

  i  12:19:14|<unknown>  Connected to stratum server coinotron.com : 3344
  i  12:19:15|<unknown>  {"error": null, "id": 1, "result": [["mining.notify", "91d0025c5ea54509977e3475d065169e"], "080016D0", 4]}
  i  12:19:15|<unknown>  Subscribed
  i  12:19:15|<unknown>  { "id": null, "method": "mining.set_difficulty", "params": [32768]}
  i  12:19:15|<unknown>  mining.set_difficulty
  i  12:19:15|<unknown>  {"params": ["31065", "0xc09361c52e9dddd141040cc79c52eaed382e92c1dd350324c040482a4c4ac0fa","0x5a46dd85298b0beff65ccf3006c4b5d2f7fa6ca8a5885a7f2132714fe7a48602","0x0000000200000000000000000000000000000000000000000000000000000000", true], "id": null, "method": "mining.notify"}
  i  12:19:15|<unknown>  mining.notify

From this I can conclude that the subscription call works. Then at the end of handleResponse, I simply queue up a new async_read_until to wait for the next line of JSON to come in from the server. This also kind of works, but the idea is that after a few seconds, new work should come in as a "mining.notify". This never happens. Can anybody explain what I'm doing wrong?

Regarding the mining.authorize call on line 113. I've understood from the documentation that I can send that whenever I want, so I tried to do this immediately after the subscribe method returned. But if I do this, it a) doesn't return and b) all lines after "Subscribed" don't come in any longer. This is the second problem I'm trying to figure out.

I'm using this as reference, but my Python is even worse than my C++

But when I run the binaries connecting to the same host (coinotron.com:3344), I do get new work coming in...

Thanks for having a look at this.