I2P: Creating SAM session with 127.0.0.1:7656 #22759

issue rebroad opened this issue on August 21, 2021
  1. rebroad commented at 8:52 AM on August 21, 2021: contributor

    This issue is either a bug, or a feature request to improve the documentation for using I2P. Currently, I have been unable to get I2P working based on the documentation so far. The I2P server is running, but the logs say that it is unable to create a SAM session.

  2. rebroad added the label Bug on Aug 21, 2021
  3. jonatack commented at 9:48 AM on August 21, 2021: contributor

    There's been some work on doc/i2p.md (#22250, #22589, now #22648, with some ideas for future documentation).

    There is also

    What platform and I2P router/version are you using (I presume you are using a Bitcoin Core 22.0 release candidate or recent master)?

  4. rebroad commented at 11:05 AM on August 22, 2021: contributor

    Thanks @jonatack I'll check out those stackexchange articles and see if the info therein helps. I'm using 22.99 (recent master), using i2p versions:-

    i2p/bionic,now 0.9.34-1ubuntu3 all [installed]
    i2p-doc/bionic 0.9.34-1ubuntu3 all
    i2p-router/bionic,now 0.9.34-1ubuntu3 all [installed,automatic]
    i2pd/bionic 2.17.0-3build1 amd64
    

    on Ubuntu 18.04.5 LTS on WSL:-

    PS C:\Users\rebroad> wsl --status
    Default Distribution: Ubuntu-18.04
    Default Version: 2
    
    Windows Subsystem for Linux was last updated on 09/07/2021
    WSL automatic updates are on.
    
    Kernel version: 5.10.43
    PS C:\Users\rebroad> wsl -l -v
      NAME            STATE           VERSION
    * Ubuntu-18.04    Running         1
    
  5. jonatack commented at 12:36 PM on August 22, 2021: contributor

    Ok, if you're using i2p-router, this comment by @Rspigler might be helpful: #22648 (review). Let me know.

  6. jonatack commented at 12:38 PM on August 22, 2021: contributor

    (I plan to post a twitter thread soon to help people get started, so any feedback at the moment is useful.)

  7. rebroad commented at 3:29 PM on August 22, 2021: contributor

    @jonatack I think i've fixed it by downloading the latest version using the dedicated repository:-

    sudo apt-add-repository ppa:i2p-maintainers/i2p

    Nope, bitcoin is still not connecting to the port. It's not listening on 7656, but there is now a web interface that works on port 7657.

  8. Rspigler commented at 12:49 AM on August 23, 2021: contributor

    Did you enable SAM? Do you see the green light? Did you run i2prouter start?

    Can you post your bitcoin.conf contents and your debug you have with debug=i2p?

    You shouldn't have to open any ports.

  9. xanoni commented at 4:52 AM on August 23, 2021: none

    For i2p (Java implementation):

    See: https://geti2p.net/en/docs/api/samv3 (scroll to very bottom)

    Default SAM Setup The default SAM port is 7656. SAM is not enabled by default in the Java I2P Router; it must be started manually, or configured to start automatically, on the configure clients page in the router console, or in the clients.config file. The default SAM UDP port is 7655, listening on 127.0.0.1. These may be changed by adding the arguments sam.udp.port=nnnnn and/or sam.udp.host=w.x.y.z to the invocation.

    Configuration in other routers is implementation-specific.

    For i2pd (C++ implementation):

    See: https://i2pd.readthedocs.io/en/latest/user-guide/configuration/

    # i2pd.conf
    [sam]
    enabled = true
    address = 127.0.0.1
    port = 7656
    
  10. rebroad commented at 9:47 AM on August 23, 2021: contributor

    ok, I have enabled the SAM port in i2p now, but now I have different errors in bitcoin's debug.log:-

    2021-08-23T09:44:13.535 AddLocal(7n57kytmqbay42cwdofju37cn3fuykdutoqdmfdrzrc37dlrzblq.b32.i2p:0,4)
    2021-08-23T09:44:13.535 I2P: Error accepting: Cannot decode Base64: "STREAM STATUS RESULT=I2P_ERROR MESSAGE="Session was closed""
    2021-08-23T09:45:14.006 I2P: Error listening: Unexpected reply to "HELLO VERSION MIN=3.1 MAX=3.1": "HELLO REPLY RESULT=I2P_ERROR MESSAGE="Timeout waiting for HELLO VERSION""
    2021-08-23T09:45:14.007 RemoveLocal(7n57kytmqbay42cwdofju37cn3fuykdutoqdmfdrzrc37dlrzblq.b32.i2p:0)
    

    The "cannot decode" message above repeats every 0.002 seconds, so ends up flooding the log file.

  11. xanoni commented at 11:48 PM on August 23, 2021: none

    "HELLO VERSION MIN=3.1 MAX=3.1"

    Do you have that ? ;-)

    Here is some info: https://geti2p.net/en/docs/api/samv3

    To implement a basic TCP-only, peer-to-peer application, the client must support the following commands.
    
    HELLO VERSION MIN=3.1 MAX=3.1
    Needed for all of the remaining ones
    DEST GENERATE SIGNATURE_TYPE=7
    To generate our private key and destination
    NAMING LOOKUP NAME=...
    To convert .i2p addresses to destinations
    SESSION CREATE STYLE=STREAM ID=... DESTINATION=...
    Needed for STREAM CONNECT and STREAM ACCEPT
    STREAM CONNECT ID=... DESTINATION=...
    To make outgoing connections
    STREAM ACCEPT ID=...
    To accept incoming connections
    

    EDIT: You likely do ...

    Version 3.1 was introduced in I2P release 0.9.14 (July 2014). 
    

    I would double check whether you specified the correct ports both on the Bitcoin and on the I2P side.

  12. Rspigler commented at 12:47 AM on August 24, 2021: contributor

    Can you post your bitcoin.conf

  13. vasild commented at 7:05 AM on August 24, 2021: contributor

    2021-08-23T09:44:13.535 I2P: Error accepting: Cannot decode Base64: "STREAM STATUS RESULT=I2P_ERROR MESSAGE="Session was closed""

    Uh, oh, so that I2P implementation is not confirming to the spec - it should reply with a base64 string, from https://geti2p.net/en/docs/api/samv3:

    If SILENT=false was passed, which is the default value, the SAM bridge sends the client a ASCII line containing the base64 public destination key of the requesting peer

    I cannot reproduce this with I2P router 0.9.50:

    terminal1> # create a new session
    terminal1> telnet 127.0.0.1 7656
    terminal1> HELLO VERSION MIN=3.1 MAX=3.1
    terminal1> # receives response: HELLO REPLY RESULT=OK VERSION=3.1
    terminal1> SESSION CREATE STYLE=STREAM ID=123 DESTINATION=TRANSIENT
    terminal1> # receives response: SESSION STATUS RESULT=OK DESTINATION=...
    terminal1> # hangs/waits...
    
    terminal2> # wait for an incoming connection on the created session
    terminal2> telnet 127.0.0.1 7656
    terminal2> HELLO VERSION MIN=3.1 MAX=3.1
    terminal2> # receives response: HELLO REPLY RESULT=OK VERSION=3.1
    terminal2> STREAM ACCEPT ID=123 SILENT=false
    terminal2> # receives response: STREAM STATUS RESULT=OK
    terminal1> # hangs/waits...
    
    terminal1> # close the socket, thus destroying the session
    terminal1> ^]
    terminal1> telnet> q
    terminal1> Connection closed.
    
    terminal2> # telnet reports that the socket is closed without any messages, as expected
    terminal2> Connection closed by foreign host.
    
  14. vasild commented at 7:12 AM on August 24, 2021: contributor

    Anyway, that does not explain what's wrong with your I2P router and why it errors. Do you see just

    2021-08-23T09:44:13.535 I2P: Error accepting: Cannot decode Base64:... 2021-08-23T09:44:13.535 I2P: Error accepting: Cannot decode Base64:... ...

    repeated every 0.002 seconds or are there other repeating messages?

  15. rebroad commented at 12:35 PM on August 24, 2021: contributor

    Anyway, that does not explain what's wrong with your I2P router and why it errors. Do you see just

    2021-08-23T09:44:13.535 I2P: Error accepting: Cannot decode Base64:... 2021-08-23T09:44:13.535 I2P: Error accepting: Cannot decode Base64:... ...

    repeated every 0.002 seconds or are there other repeating messages?

    these are the only messages that are repeated.

  16. xanoni commented at 3:57 PM on August 24, 2021: none

    And you are sure it's connecting to the correct port? Lots of ports used by I2P so it's easy to get confused ..

  17. fanquake commented at 4:36 PM on August 8, 2022: member

    Going to close for now until some new / actionable information is available. This does not seem like a bug in Bitcoin Core.

  18. fanquake closed this on Aug 8, 2022

  19. Sataur commented at 7:35 PM on June 20, 2023: none

    definitely should be improved on return from system sleep Error accepting: Cannot decode Base64: "STREAM STATUS RESULT=I2P_ERROR MESSAGE="Session was closed"" and repeat same message hundreds time per second! Version: 2.2.1-0 Core 25 / Mint CRIT [acket pusher] net.i2p.util.Clock : Large clock shift forward by __m

  20. jonatack commented at 8:17 PM on June 20, 2023: contributor

    The "cannot decode" message above repeats every 0.002 seconds, so ends up flooding the log file.

    "Cannot decode Base64: "STREAM STATUS RESULT=I2P_ERROR MESSAGE="Session was closed"" and repeat same message hundreds time per second!

    Indeed, I have a few instances in my mainnet debug log when this occurred, and like these reports, in high-frequency bursts (unsure, but they seem to have only happened when using the Java I2P router, not i2pd). Will look more into it.

  21. jonatack commented at 8:26 PM on June 20, 2023: contributor

    For i2p (Java implementation):

    See: geti2p.net/en/docs/api/samv3 (scroll to very bottom)

    SAM is not enabled by default in the Java I2P Router; it must be started manually, or configured to start automatically, on the configure clients page in the router console, or in the clients.config file.

    Good point. People ask often enough about starting the SAM bridge in the Java I2P router, and the info is fairly hard to find for someone just looking to get started with I2P for their node.

    Will propose to update doc/i2p.md to clarify it. Edit: done in #27937.

  22. jonatack commented at 5:01 PM on June 27, 2023: contributor

    The "cannot decode" message above repeats every 0.002 seconds, so ends up flooding the log file.

    "Cannot decode Base64: "STREAM STATUS RESULT=I2P_ERROR MESSAGE="Session was closed"" and repeat same message hundreds time per second!

    Indeed, I have a few instances in my mainnet debug log when this occurred, and like these reports, in high-frequency bursts (unsure, but they seem to have only happened when using the Java I2P router, not i2pd). Will look more into it.

    I've seen this a couple more times lately, including this morning, with I2P router v1.9.0 on macOS 13.4.1.

    It can occur, for instance, on awaking the laptop after it auto-shutdown due to low battery, and the SAM bridge is down and needs a restart, whereas bitcoind/tor/cjdns continue running.

    2023-06-27T12:19:35.638318Z [scheduler] [net_processing.cpp:5212] [CheckForStaleTipAndEvictPeers] Potential stale tip detected, will try using extra outbound peer (last tip update: 18927 seconds ago)
    2023-06-27T12:19:35.751795Z [i2paccept] [i2p.cpp:257] [Log] [i2p] Error accepting: Cannot decode Base64: "STREAM STATUS RESULT=I2P_ERROR"
    2023-06-27T12:19:35.754129Z [i2paccept] [i2p.cpp:257] [Log] [i2p] Error accepting: Cannot decode Base64: "STREAM STATUS RESULT=I2P_ERROR MESSAGE="Session was closed""
    2023-06-27T12:19:35.756923Z [i2paccept] [i2p.cpp:257] [Log] [i2p] Error accepting: Cannot decode Base64: "STREAM STATUS RESULT=I2P_ERROR MESSAGE="Session was closed""
    2023-06-27T12:19:35.758073Z [i2paccept] [i2p.cpp:257] [Log] [i2p] Error accepting: Cannot decode Base64: "STREAM STATUS RESULT=I2P_ERROR MESSAGE="Session was closed""
    .../...
    2023-06-27T12:25:10.481379Z [i2paccept] [i2p.cpp:257] [Log] [i2p] Error accepting: Cannot decode Base64: "STREAM STATUS RESULT=I2P_ERROR MESSAGE="Session was closed""
    2023-06-27T12:25:10.481731Z [i2paccept] [i2p.cpp:257] [Log] [i2p] Error accepting: Cannot decode Base64: "STREAM STATUS RESULT=I2P_ERROR MESSAGE="Session was closed""
    2023-06-27T12:25:10.482109Z [i2paccept] [i2p.cpp:257] [Log] [i2p] Error accepting: Cannot decode Base64: "STREAM STATUS RESULT=I2P_ERROR MESSAGE="Session was closed""
    2023-06-27T12:25:10.482484Z [i2paccept] [i2p.cpp:257] [Log] [i2p] Error accepting: Cannot decode Base64: "STREAM STATUS RESULT=I2P_ERROR MESSAGE="Session was closed""
    2023-06-27T12:25:15.487624Z [i2paccept] [i2p.cpp:257] [Log] [i2p] Error listening: Cannot connect to 127.0.0.1:7656
    2023-06-27T12:25:15.487658Z [i2paccept] [net.cpp:318] [RemoveLocal] RemoveLocal(<redacted>.b32.i2p:0)
    .../...
    2023-06-27T12:26:07.328142Z [opencon] [i2p.cpp:257] [Log] [i2p] Creating persistent SAM session ea8f7bdf7c with 127.0.0.1:7656
    2023-06-27T12:26:09.776993Z [opencon] [i2p.cpp:257] [Log] [i2p] Persistent SAM session ea8f7bdf7c created, my address=<redacted>.b32.i2p:0
    
  23. fanquake referenced this in commit 2cd71d3a13 on Jun 30, 2023
  24. jonatack commented at 1:22 PM on July 7, 2023: contributor
  25. vasild referenced this in commit 849355f850 on Jul 7, 2023
  26. vasild referenced this in commit 01719bb98b on Jul 10, 2023
  27. vasild referenced this in commit ad7c11d9c5 on Jul 14, 2023
  28. vasild referenced this in commit 3870734270 on Jul 14, 2023
  29. jonatack commented at 3:49 PM on July 14, 2023: contributor

    @rebroad @Sataur A fix to the issue you described has been proposed in #28077, if you'd like to test it.

  30. luke-jr referenced this in commit 9d5afbdc36 on Sep 16, 2023
  31. vasild referenced this in commit 762404a68c on Oct 5, 2023
  32. luke-jr referenced this in commit 3e316169e2 on Oct 19, 2023
  33. achow101 referenced this in commit 77f0ceb717 on Oct 19, 2023
  34. Frank-GER referenced this in commit 2389eef67a on Oct 21, 2023
  35. janus referenced this in commit af68f3b4c3 on Apr 1, 2024
  36. bitcoin locked this on Jul 13, 2024

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-14 21:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me