Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: Could not connect to the server 127.0.0.1:8331 (error code 1 - "EOF reached") on openbsd #17

Open
ghost opened this issue Aug 5, 2021 · 8 comments
Labels
bug Something isn't working help wanted Extra attention is needed question Further information is requested

Comments

@ghost
Copy link

ghost commented Aug 5, 2021

  1. running cargo run --release -- --conf btc_rpc_proxy.toml with:
bitcoind_user = "nathanael"
bitcoind_password = "[redacted]"
bind_address = "127.0.0.1"

[user.test]
password = "test"
allowed_calls = [
        "getmininginfo"
]
  1. running bitcoin-cli -rpcuser=test -rpcpassword=test -rpcport=8331 getmininginfo:
error: Could not connect to the server 127.0.0.1:8331 (error code 1 - "EOF reached")

Make sure the bitcoind server is running and that you are connecting to the correct RPC port.

the proxy is running cause netstat -na -f inet | grep 8331 gives me:

tcp          0      0  127.0.0.1.8331         *.*                    LISTEN

of course when i run bitcoin-cli -rpcuser=nathanael -rpcpassword=[redacted] getmininginfo it works (using the values inserted in the config file of btc-rpcy-proxy seen above)

has anyone an idea what i am doing wrong? something to do with openbsd?

@Kixunil
Copy link
Owner

Kixunil commented Aug 5, 2021

Hi, sorry for not replying to your e-mail, last couple of days were terrible.

One more thing that comes to my mind is try to use cookie authentication. Maybe we've screwed up password authentication and I'm not sure if anyone actually tested it, since cookie files are better. Although the code looks correct from what I can tell.

@Kixunil Kixunil added bug Something isn't working question Further information is requested help wanted Extra attention is needed labels Aug 5, 2021
@ghost
Copy link
Author

ghost commented Aug 5, 2021

no problem at all, thought so, maybe someone else can help or has already had the same problem

i tried in the config cookie_file = "/path/to/cookie/file" instead of bitcoind_user and bitcoind_password. then i tried bitcoin-cli -rpcport=8331 getmininginfo and of course it said error: Authorization failed: Incorrect rpcuser or rpcpassword then bitcoin-cli -rpcuser=test -rpcpassword=test -rpcport=8331 resultet in the same error as mentioned above

is that what you meant with using the cookie authentication?

@Kixunil
Copy link
Owner

Kixunil commented Aug 5, 2021

Did you set /path/to/cookie/file to the actual cookie file used by bitcoind?

@ghost
Copy link
Author

ghost commented Aug 5, 2021

Did you set /path/to/cookie/file to the actual cookie file used by bitcoind?

yes

@Kixunil
Copy link
Owner

Kixunil commented Aug 5, 2021

Could you run Wireshark or a similar tool to catch streams of those apps communicating? Ideally catch both bitcoin-cli -> btc-rpc-proxy and btc-rpc-proxy -> bitcoind; possibly also bitcoin-cli -> bitcoind

Don't forget to censor authentication if you post it, but also compare if latter two match.

@ghost
Copy link
Author

ghost commented Aug 5, 2021

i never used wireshark - this is what i get using tshark (the command line tool of wireshark):

bitcoin-cli -> btc-rpc-proxy

    1   0.000000    127.0.0.1 → 127.0.0.1    TCP 68 7750 → 8331 [SYN] Seq=0 Win=16384 Len=0 MSS=32728 SACK_PERM=1 WS=64 TSval=3876093742 TSecr=0
    2   0.000028    127.0.0.1 → 127.0.0.1    TCP 68 8331 → 7750 [SYN, ACK] Seq=0 Ack=1 Win=16384 Len=0 MSS=32728 SACK_PERM=1 WS=64 TSval=174447773 TSecr=3876093742
    3   0.000037    127.0.0.1 → 127.0.0.1    TCP 56 7750 → 8331 [ACK] Seq=1 Ack=1 Win=16384 Len=0 TSval=3876093742 TSecr=174447773
    4   0.000147    127.0.0.1 → 127.0.0.1    HTTP/JSON 244 POST / HTTP/1.1 , JavaScript Object Notation (application/json)
    5   0.000153    127.0.0.1 → 127.0.0.1    TCP 56 8331 → 7750 [ACK] Seq=1 Ack=189 Win=16192 Len=0 TSval=174447773 TSecr=3876093742
    6   0.000469    127.0.0.1 → 127.0.0.1    TCP 56 8331 → 7750 [FIN, ACK] Seq=1 Ack=189 Win=16384 Len=0 TSval=174447773 TSecr=3876093742
    7   0.000477    127.0.0.1 → 127.0.0.1    TCP 56 7750 → 8331 [ACK] Seq=189 Ack=2 Win=16384 Len=0 TSval=3876093742 TSecr=174447773
    8   0.000519    127.0.0.1 → 127.0.0.1    TCP 56 7750 → 8331 [FIN, ACK] Seq=189 Ack=2 Win=16384 Len=0 TSval=3876093742 TSecr=174447773
    9   0.000531    127.0.0.1 → 127.0.0.1    TCP 56 8331 → 7750 [ACK] Seq=2 Ack=190 Win=16384 Len=0 TSval=174447773 TSecr=3876093742

btc-rpc-proxy -> bitcoind

    1   0.000000    127.0.0.1 → 127.0.0.1    TCP 68 40100 → 8332 [SYN] Seq=0 Win=16384 Len=0 MSS=32728 SACK_PERM=1 WS=64 TSval=3651821960 TSecr=0
    2   0.000013    127.0.0.1 → 127.0.0.1    TCP 68 8332 → 40100 [SYN, ACK] Seq=0 Ack=1 Win=16384 Len=0 MSS=32728 SACK_PERM=1 WS=64 TSval=3286890545 TSecr=3651821960
    3   0.000020    127.0.0.1 → 127.0.0.1    TCP 56 40100 → 8332 [ACK] Seq=1 Ack=1 Win=16384 Len=0 TSval=3651821960 TSecr=3286890545
    4   0.000145    127.0.0.1 → 127.0.0.1    TCP 56 40100 → 8332 [FIN, ACK] Seq=1 Ack=1 Win=16384 Len=0 TSval=3651821960 TSecr=3286890545
    5   0.000158    127.0.0.1 → 127.0.0.1    TCP 56 8332 → 40100 [ACK] Seq=1 Ack=2 Win=16384 Len=0 TSval=3286890545 TSecr=3651821960
    6   0.000260    127.0.0.1 → 127.0.0.1    TCP 56 8332 → 40100 [FIN, ACK] Seq=1 Ack=2 Win=16384 Len=0 TSval=3286890545 TSecr=3651821960
    7   0.000268    127.0.0.1 → 127.0.0.1    TCP 56 40100 → 8332 [ACK] Seq=2 Ack=2 Win=16384 Len=0 TSval=3651821960 TSecr=3286890545

bitcoin-cli -> bitcoind

    1   0.000000    127.0.0.1 → 127.0.0.1    TCP 68 47952 → 8332 [SYN] Seq=0 Win=16384 Len=0 MSS=32728 SACK_PERM=1 WS=64 TSval=1563923267 TSecr=0
    2   0.000026    127.0.0.1 → 127.0.0.1    TCP 68 8332 → 47952 [SYN, ACK] Seq=0 Ack=1 Win=16384 Len=0 MSS=32728 SACK_PERM=1 WS=64 TSval=1618734967 TSecr=1563923267
    3   0.000033    127.0.0.1 → 127.0.0.1    TCP 56 47952 → 8332 [ACK] Seq=1 Ack=1 Win=16384 Len=0 TSval=1563923267 TSecr=1618734967
    4   0.000113    127.0.0.1 → 127.0.0.1    HTTP/JSON 300 POST / HTTP/1.1 , JavaScript Object Notation (application/json)
    5   0.000125    127.0.0.1 → 127.0.0.1    TCP 56 8332 → 47952 [ACK] Seq=1 Ack=245 Win=16128 Len=0 TSval=1618734967 TSecr=1563923267
    6   0.000502    127.0.0.1 → 127.0.0.1    HTTP/JSON 347 HTTP/1.1 200 OK , JavaScript Object Notation (application/json)
    7   0.000517    127.0.0.1 → 127.0.0.1    TCP 56 47952 → 8332 [ACK] Seq=245 Ack=292 Win=16064 Len=0 TSval=1563923267 TSecr=1618734967
    8   0.000531    127.0.0.1 → 127.0.0.1    TCP 56 8332 → 47952 [FIN, ACK] Seq=292 Ack=245 Win=16384 Len=0 TSval=1618734967 TSecr=1563923267
    9   0.000537    127.0.0.1 → 127.0.0.1    TCP 56 47952 → 8332 [ACK] Seq=245 Ack=293 Win=16064 Len=0 TSval=1563923267 TSecr=1618734967
   10   0.000579    127.0.0.1 → 127.0.0.1    TCP 56 47952 → 8332 [FIN, ACK] Seq=245 Ack=293 Win=16384 Len=0 TSval=1563923267 TSecr=1618734967
   11   0.000590    127.0.0.1 → 127.0.0.1    TCP 56 8332 → 47952 [ACK] Seq=293 Ack=246 Win=16384 Len=0 TSval=1618734967 TSecr=1563923267

no clue where i should have censored here something, but i just used throwaway username and password for the requests and apperently the latter two don't match

@Kixunil
Copy link
Owner

Kixunil commented Aug 5, 2021

That looks like some kind of high-level overview of packets. Wireshark has "follow TCP stream" feature which is needed - it shows directly data (bytes) transferred.

@ghost
Copy link
Author

ghost commented Aug 5, 2021

bitcoin-cli -> btc-rpc-proxy

Follow: tcp,hex
Filter: tcp.stream eq 0
Node 0: 127.0.0.1:39721
Node 1: 127.0.0.1:8331
00000000  50 4f 53 54 20 2f 20 48  54 54 50 2f 31 2e 31 0d  POST / H TTP/1.1.
00000010  0a 48 6f 73 74 3a 20 31  32 37 2e 30 2e 30 2e 31  .Host: 1 27.0.0.1
00000020  0d 0a 43 6f 6e 6e 65 63  74 69 6f 6e 3a 20 63 6c  ..Connec tion: cl
00000030  6f 73 65 0d 0a 43 6f 6e  74 65 6e 74 2d 54 79 70  ose..Con tent-Typ
00000040  65 3a 20 61 70 70 6c 69  63 61 74 69 6f 6e 2f 6a  e: appli cation/j
00000050  73 6f 6e 0d 0a 41 75 74  68 6f 72 69 7a 61 74 69  son..Aut horizati
00000060  6f 6e 3a 20 42 61 73 69  63 20 64 47 56 7a 64 44  on: Basi c dGVzdD
00000070  70 30 5a 58 4e 30 0d 0a  43 6f 6e 74 65 6e 74 2d  p0ZXN0.. Content-
00000080  4c 65 6e 67 74 68 3a 20  34 36 0d 0a 0d 0a 7b 22  Length:  46....{"
00000090  6d 65 74 68 6f 64 22 3a  22 67 65 74 6d 69 6e 69  method": "getmini
000000A0  6e 67 69 6e 66 6f 22 2c  22 70 61 72 61 6d 73 22  nginfo", "params"
000000B0  3a 5b 5d 2c 22 69 64 22  3a 31 7d 0a              :[],"id" :1}.

btc-rpc-proxy -> bitcoind

Follow: tcp,hex
Filter: tcp.stream eq 0
Node 0: 127.0.0.1:35139
Node 1: 127.0.0.1:8332

bitcoin-cli -> bitcoind

Follow: tcp,hex
Filter: tcp.stream eq 0
Node 0: 127.0.0.1:43453
Node 1: 127.0.0.1:8332
00000000  50 4f 53 54 20 2f 20 48  54 54 50 2f 31 2e 31 0d  POST / H TTP/1.1.
00000010  0a 48 6f 73 74 3a 20 31  32 37 2e 30 2e 30 2e 31  .Host: 1 27.0.0.1
00000020  0d 0a 43 6f 6e 6e 65 63  74 69 6f 6e 3a 20 63 6c  ..Connec tion: cl
00000030  6f 73 65 0d 0a 43 6f 6e  74 65 6e 74 2d 54 79 70  ose..Con tent-Typ
00000040  65 3a 20 61 70 70 6c 69  63 61 74 69 6f 6e 2f 6a  e: appli cation/j
00000050  73 6f 6e 0d 0a 41 75 74  68 6f 72 69 7a 61 74 69  son..Aut horizati
00000060  6f 6e 3a 20 42 61 73 69  63 20 64 47 56 7a 64 44  on: Basi c dGVzdD
00000070  70 58 52 6c 39 6f 64 44  45 30 56 6e 4d 33 4d 57  pXRl9odD E0VnM3MW
00000080  4a 4e 64 31 39 54 62 46  46 50 51 6e 52 7a 54 45  JNd19TbF FPQnRzTE
00000090  56 6a 61 6d 63 31 61 6b  4a 51 52 55 31 59 65 69  Vjamc1ak JQRU1Yei
000000A0  31 49 63 6c 42 45 62 30  31 7a 50 51 3d 3d 0d 0a  1IclBEb0 1zPQ==..
000000B0  43 6f 6e 74 65 6e 74 2d  4c 65 6e 67 74 68 3a 20  Content- Length:
000000C0  34 36 0d 0a 0d 0a 7b 22  6d 65 74 68 6f 64 22 3a  46....{" method":
000000D0  22 67 65 74 6d 69 6e 69  6e 67 69 6e 66 6f 22 2c  "getmini nginfo",
000000E0  22 70 61 72 61 6d 73 22  3a 5b 5d 2c 22 69 64 22  "params" :[],"id"
000000F0  3a 31 7d 0a                                       :1}.
        00000000  48 54 54 50 2f 31 2e 31  20 32 30 30 20 4f 4b 0d  HTTP/1.1  200 OK.
        00000010  0a 43 6f 6e 74 65 6e 74  2d 54 79 70 65 3a 20 61  .Content -Type: a
        00000020  70 70 6c 69 63 61 74 69  6f 6e 2f 6a 73 6f 6e 0d  pplicati on/json.
        00000030  0a 44 61 74 65 3a 20 54  68 75 2c 20 30 35 20 41  .Date: T hu, 05 A
        00000040  75 67 20 32 30 32 31 20  32 31 3a 34 38 3a 33 32  ug 2021  21:48:32
        00000050  20 47 4d 54 0d 0a 43 6f  6e 74 65 6e 74 2d 4c 65   GMT..Co ntent-Le
        00000060  6e 67 74 68 3a 20 31 36  33 0d 0a 43 6f 6e 6e 65  ngth: 16 3..Conne
        00000070  63 74 69 6f 6e 3a 20 63  6c 6f 73 65 0d 0a 0d 0a  ction: c lose....
        00000080  7b 22 72 65 73 75 6c 74  22 3a 7b 22 62 6c 6f 63  {"result ":{"bloc
        00000090  6b 73 22 3a 36 39 34 33  37 38 2c 22 64 69 66 66  ks":6943 78,"diff
        000000A0  69 63 75 6c 74 79 22 3a  31 34 34 39 36 34 34 32  iculty": 14496442
        000000B0  38 35 36 33 34 39 2e 31  32 2c 22 6e 65 74 77 6f  856349.1 2,"netwo
        000000C0  72 6b 68 61 73 68 70 73  22 3a 31 2e 32 38 39 31  rkhashps ":1.2891
        000000D0  39 33 39 38 39 30 35 34  38 34 36 65 2b 32 30 2c  93989054 846e+20,
        000000E0  22 70 6f 6f 6c 65 64 74  78 22 3a 32 32 38 39 2c  "pooledt x":2289,
        000000F0  22 63 68 61 69 6e 22 3a  22 6d 61 69 6e 22 2c 22  "chain": "main","
        00000100  77 61 72 6e 69 6e 67 73  22 3a 22 22 7d 2c 22 65  warnings ":""},"e
        00000110  72 72 6f 72 22 3a 6e 75  6c 6c 2c 22 69 64 22 3a  rror":nu ll,"id":
        00000120  31 7d 0a                                          1}.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant