Skip to content

Commit

Permalink
debug ping error
Browse files Browse the repository at this point in the history
  • Loading branch information
diegomrsantos committed Apr 22, 2024
1 parent b30b265 commit 760cb78
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions libp2p/protocols/ping.nim
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,19 @@ proc new*(T: typedesc[Ping], handler: PingHandler = nil, rng: ref HmacDrbgContex

method init*(p: Ping) =
proc handle(conn: Connection, proto: string) {.async.} =
var buf: array[PingSize, byte]
try:
trace "handling ping", conn
var buf: array[PingSize, byte]
await conn.readExactly(addr buf[0], PingSize)
trace "echoing ping", conn
trace "echoing ping", conn, pingData = @buf
await conn.write(@buf)
if not isNil(p.pingHandler):
await p.pingHandler(conn.peerId)
except CancelledError as exc:
trace "cancelled error in ping handler", exc = exc.msg, conn, pingData = @buf
raise exc
except CatchableError as exc:
trace "exception in ping handler", exc = exc.msg, conn
trace "exception in ping handler", exc = exc.msg, conn, pingData = @buf

p.handler = handle
p.codec = PingCodec
Expand Down
2 changes: 1 addition & 1 deletion tests/transport-interop/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ COPY . nim-libp2p/

RUN \
cd nim-libp2p && \
nim c --skipProjCfg --skipParentCfg --NimblePath:./nimbledeps/pkgs -p:nim-libp2p -d:chronicles_log_level=WARN --threads:off ./tests/transport-interop/main.nim
nim c --skipProjCfg --skipParentCfg --NimblePath:./nimbledeps/pkgs -p:nim-libp2p -d:chronicles_log_level=TRACE --threads:off ./tests/transport-interop/main.nim

ENTRYPOINT ["/app/nim-libp2p/tests/transport-interop/main"]

0 comments on commit 760cb78

Please sign in to comment.