I am trying to send a new order to binance api, through self implemented http2.0 from scratch. I managed to send requests to public endpoints, e.g. “GET /api/v3/exchangeInfo”. It works fine. I follow the steps described in https://www.rfc-editor.org/rfc/rfc9113. I connect to the endpoint, send a connection preface, the window update frame, build the request, and send it. For requests like the one above everything works as expected.
However, when I try to send a signed request, such as a new order (Binance API Documentation), it breaks. Again, I manage to connect, send the connection preface, window update frame and receive the answer from the server, but right after I send the new order request, I receive a rst_stream frame, with the error code : protocol error. The request I send is
1 // type
5 // end headers + end stream flag
0 0 0 1 // id 1
131 // method post
135 // scheme https
17 22 testnet.binance.vision // authority
31 23 22 testnet.binance.vision // host
16 5 :path
127 140 1 /api/v3/order?symbol=BTCUSDT&price=29115.0000&quantity=0.010000000000000000&newOrderRespType=RESULT&side=SELL&type=LIMIT_MAKER&newClientOrderId=TJi2YxkW&recvWindow=5000×tamp=1688382600142&signature=a32dc861a30107eaf126cfcde5d4d85a1c5dcc167af86a135cfa80ffdafb2586
16 12 X-MBX-APIKEY 64 RDsd2fXisWZKjtftR8Koswd1x24HTaBEFVwQOPZ9ERe9jUxu6v82uPxBtQ50IBa9
I checked that all the lengths are correct, and also the signature for the given key (but that being wrong should not result in a protocol error anyways). For the above request, I wrote readable ascii bytes as characters, and the other ones (such as lengths, etc) as numbers for readability.