Improve stratum error handling #62

Open
opened 3 years ago by duke · 0 comments
duke commented 3 years ago
Owner

I started to submit invalid requests to the Stratum port to see how it handles them. Not horrible, but not great either.

curl --data '{"id": 1, "method": "mining.subscribe", "params": ["CONNECT_HOST", CONNECT_PORT, "MINER_USER_AGENT", "SESSION_ID"]}'  http://localhost:19031

returns this:

{"result":null,"error":{"code":-32700,"message":"Invalid JSON, Parse error on: POST / HTTP/1.1"},"id":null}
{"result":null,"error":{"code":-32700,"message":"Invalid JSON, Parse error on: Host: localhost:19031"},"id":null}
{"result":null,"error":{"code":-32700,"message":"Invalid JSON, Parse error on: User-Agent: curl/7.64.0"},"id":null}
{"result":null,"error":{"code":-32700,"message":"Invalid JSON, Parse error on: Accept: */*"},"id":null}
{"result":null,"error":{"code":-32700,"message":"Invalid JSON, Parse error on: Content-Length: 115"},"id":null}
{"result":null,"error":{"code":-32700,"message":"Invalid JSON, Parse error on: Content-Type: application/x-www-form-urlencoded"},"id":null}
{"result":null,"error":{"code":-32700,"message":"Invalid JSON, Parse error on: "},"id":null}

and also hangs until a CTRL-C is given. We should abort on the first parse error, we should not parse HTTP headers as json and close the connection as well. And also log the invalid request in debug.log.

I started to submit invalid requests to the Stratum port to see how it handles them. Not horrible, but not great either. ``` curl --data '{"id": 1, "method": "mining.subscribe", "params": ["CONNECT_HOST", CONNECT_PORT, "MINER_USER_AGENT", "SESSION_ID"]}' http://localhost:19031 ``` returns this: ``` {"result":null,"error":{"code":-32700,"message":"Invalid JSON, Parse error on: POST / HTTP/1.1"},"id":null} {"result":null,"error":{"code":-32700,"message":"Invalid JSON, Parse error on: Host: localhost:19031"},"id":null} {"result":null,"error":{"code":-32700,"message":"Invalid JSON, Parse error on: User-Agent: curl/7.64.0"},"id":null} {"result":null,"error":{"code":-32700,"message":"Invalid JSON, Parse error on: Accept: */*"},"id":null} {"result":null,"error":{"code":-32700,"message":"Invalid JSON, Parse error on: Content-Length: 115"},"id":null} {"result":null,"error":{"code":-32700,"message":"Invalid JSON, Parse error on: Content-Type: application/x-www-form-urlencoded"},"id":null} {"result":null,"error":{"code":-32700,"message":"Invalid JSON, Parse error on: "},"id":null} ``` and also hangs until a CTRL-C is given. We should abort on the first parse error, we should not parse HTTP headers as json and close the connection as well. And also log the invalid request in debug.log.
duke added the
bug
label 1 year ago
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.