Skip to content

react-native-tcp-socket dial problems #2

@achingbrain

Description

@achingbrain

libp2p:connection-manager:dial-queue:error dial failed to /ip4/195.242.89.232/tcp/10265/p2p/QmSfuJdgrFzuCCXL4rBfgMpKbQcdR9Q5g3mXiDuKiPKQy3 +0ms [Error: Exception in HostFunction: Malformed calls from JS: field sizes are different.

Debug data:

[
  [34,34,36,66,66,66,66,66,66,34],
  [0,1,1,11,11,11,11,11,0,0],
  [
    [6643,2000,1705490345996,false],
    [6643],
     ["{\"type\":\"log\",\"level\":\"debug\",\"mode\":\"BRIDGE\",\"data\": [\"libp2p:tcp dialing /ip4/195.242.89.232/tcp/10265/p2p/QmSfuJdgrFzuCCXL4rBfgMpKbQcdR9Q5g3mXiDuKiPKQy3 +239ms\"]}",1],
     ["data"],
     ["error"],
     ["close"],
     ["connect"],
     ["written"],
     [6650,100,1705490346236,false]
  ],
  1217
]

From: https://stackoverflow.com/questions/55084493/malformed-calls-from-js-field-sizes-are-different

Step 1: Add the following code snippet anywhere in your code:

if (global.__fbBatchedBridge) {
  const origMessageQueue = global.__fbBatchedBridge;
  const modules = origMessageQueue._remoteModuleTable;
  const methods = origMessageQueue._remoteMethodTable;
  global.findModuleByModuleAndMethodIds = (moduleId, methodId) => {
    console.log(`The problematic line code is in: ${modules[moduleId]}.${methods[moduleId][methodId]}`)
  }
}

Step 2: All you have to do now is set a breakpoint anywhere in your app, and try the pairs of module/method id's as parameters of the global.findModuleByModuleAndMethodIds function like so:

global.findModuleByModuleAndMethodIds(74, 19);
global.findModuleByModuleAndMethodIds(24, 1);

Step 3: Investigate each of those calls, and look for wrong/weird parameters, you pass to those native functions.

Output

> findModuleByModuleAndMethodIds(34, 0)
The problematic line code is in: Timing.createTimer
> findModuleByModuleAndMethodIds(34, 1)
The problematic line code is in: Timing.deleteTimer
> findModuleByModuleAndMethodIds(36, 1)
The problematic line code is in: WebSocketModule.send
> findModuleByModuleAndMethodIds(66, 11)
The problematic line code is in: TcpSockets.addListener
> findModuleByModuleAndMethodIds(66, 0)
The problematic line code is in: TcpSockets.connect

Given that the bridge data contains:

     ["data"],
     ["error"],
     ["close"],
     ["connect"],
     ["written"],

... and these are event listeners, and that we're trying to dial a TCP multiaddr, TcpSockets.addListener is probably where the error is since there should be a callback function as a second arg.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions