go-libp2p-examples
go-libp2p-examples copied to clipboard
Error protocol not supported
I was trying out the examples and it panics at the following line with the error protocol not supported.
stream, err := node.NewStream(ctx, peer.ID, protocol.ID("/plaintext/2.0.0"))
I tried the one mentioned in the example "/chat/1.0.0" as well. Where do I define this ?
The host
sets the handler for a protocol
, and then can new a stream to this host
h.SetStreamHandler("/echo/1.0.0", func(s network.Stream) {
if err := doEcho(s); err != nil {
log.Println(err)
_ = s.Reset()
} else {
_ = s.Close()
}
})
basicHost.NewStream(context.Background(), peerid, "/echo/1.0.0")