go-libp2p-examples icon indicating copy to clipboard operation
go-libp2p-examples copied to clipboard

Error protocol not supported

Open thevzurd opened this issue 5 years ago • 1 comments

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 ?

thevzurd avatar Dec 03 '19 00:12 thevzurd

The host sets the handler for a protocol, and then can new a stream to this host

main.go#L104

h.SetStreamHandler("/echo/1.0.0", func(s network.Stream) {
	if err := doEcho(s); err != nil {
		log.Println(err)
		_ = s.Reset()
	} else {
		_ = s.Close()
	}
})

main.go#L150

basicHost.NewStream(context.Background(), peerid, "/echo/1.0.0")

joelcho avatar Aug 31 '20 03:08 joelcho