-
Notifications
You must be signed in to change notification settings - Fork 445
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: stream reset when pinging /p2p-circuit relay addresses concurrently #1530
Comments
Same problem when more than 30 parallel streams are open between 2 nodes. Here is the error:
Sample code to reproduce the issue: import { tcp } from "@libp2p/tcp";
import { mplex } from "@libp2p/mplex";
import { noise } from "@chainsafe/libp2p-noise";
import { createLibp2p } from "libp2p";
import { pipe } from "it-pipe";
import { toString as uint8ArrayToString } from "uint8arrays/to-string";
import { fromString as uint8ArrayFromString } from "uint8arrays/from-string";
const createNode = async () => {
const node = await createLibp2p({
addresses: {
listen: ["/ip4/127.0.0.1/tcp/0"],
},
transports: [tcp()],
streamMuxers: [mplex()],
connectionEncryption: [noise()],
});
await node.start();
return node;
};
(async () => {
const listenerNode = await createNode();
// Log a message when we receive a connection
listenerNode.connectionManager.addEventListener("peer:connect", (evt) => {
const connection = evt.detail;
console.log("Received dial from:", connection.remotePeer.toString());
});
// echo protocol
await listenerNode.handle("/echo/1.0.0", async ({ stream }) => {
await pipe(stream.source, stream.sink);
stream.close();
});
// ================= DIALER ============
const dialerNode = await createNode();
async function callProcess() {
for (let i = 0; i < 50; i++) {
console.log(`i: ${i}`);
// Dial the listener node
const stream = await dialerNode.dialProtocol(
listenerNode.getMultiaddrs()[0],
"/echo/1.0.0"
);
await pipe(
// Source data
[uint8ArrayFromString(`hey [${i}]`)],
// Write to the stream, and pass its output to the next function
stream,
// Sink function
async function(source) {
// For each chunk of data
for await (const data of source) {
// Output the data
console.log("Received echo:", uint8ArrayToString(data.subarray()));
}
}
);
// stream.close();
}
}
// parallel streams
const PARALLEL_CALLS = 40; // 30 works fine
await Promise.all(new Array(PARALLEL_CALLS).fill(0).map((i) => callProcess()));
console.log("all done");
})();
|
Same error when using js-libp2p-yamux as the streamMuxer. |
You are hitting stream limits. When you register your handler you need to increase the default limits: // echo protocol
await listenerNode.handle("/echo/1.0.0", async ({ stream }) => {
await pipe(stream.source, stream.sink);
stream.close();
}, {
maxInboundStreams: /* something sensible */,
maxOutboundStreams: /* something sensible */
}); The value of See LIMITS.md#stream-limits for more. |
Oops, seems like we needed more information for this issue, please comment with more details or this issue will be closed in 7 days. |
This issue was closed because it is missing author input. |
Version:
0.41.0
Platform:
Ubuntu:
Linux ********* 5.15.79.1-microsoft-standard-WSL2 #1 SMP Wed Nov 23 01:01:46 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Chrome:
108.0.5359.125 (Official Build) (64-bit) (cohort: Stable)
Subsystem:
Unsure, likely a combination of ping and circuit relay
Severity:
Medium High
Description:
What you did
I attempted to concurrently ping a list of multiaddrs that included
/p2p-circuit
addresses.What happened
Many of the ping attempts failed with the error
Error: stream reset
(sometimes with different stream errors)What you expected to happen
All of the ping attempts should have succeeded, since these were all healthy addresses.
Steps to reproduce the error:
Find a reproduction with instructions at: https://github.com/JoshuaCWebDeveloper/libp2p-concurrent-ping
Key points:
/p2p-circuit
address (this error does not happen if none of the addresses are relay addresses).The text was updated successfully, but these errors were encountered: