ipfs-shipyard / ipfs-shipyard/js-libp2p-react-native

react-native-tcp-socket dial problems

Open
#2 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
11
Forks
5
PR merge metrics
No merged PRs in 30d

Description

> 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:

```json
[
[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:

```js
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

```console
> findModuleByModuleAndMethodIds(34, 0)
The problematic line code is in: Timing.createTimer
```

```console
> findModuleByModuleAndMethodIds(34, 1)
The problematic line code is in: Timing.deleteTimer
```

```console
> findModuleByModuleAndMethodIds(36, 1)
The problematic line code is in: WebSocketModule.send
```

```console
> findModuleByModuleAndMethodIds(66, 11)
The problematic line code is in: TcpSockets.addListener
```

```console
> 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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.