libp2p / go-libp2p-http

HTTP on top of libp2p
MIT License
63 stars 20 forks source link

Upgrading to websockets connection #94

Open alrevuelta opened 8 months ago

alrevuelta commented 8 months ago

This repo allows HTTP requests via libp2p. I was wondering if it would be possible to reuse that to upgrade the connections to WebSockets, having then an open stream between the client and the libp2p host, so that both can write data to it.

In other words:

i) and ii) should be pretty similar to the examples in this repo, but unsure if iii) is possible or if it even makes sense.

hsanjuan commented 8 months ago

I don't see why not, but this library provides is an HTTP client and maybe you need a websocket client mounted on top of go-libp2p-gostream directly (and a websocket server instead of the normal one we use).

Also, know that the current libp2p team kind-of rewrote this library, I think: https://github.com/libp2p/go-libp2p/blob/master/p2p/http/libp2phttp.go (see https://github.com/libp2p/specs/blob/d8850aa6d0581558ac94fd1fe908ff4a72e80eda/http/README.md). While it is focused on doing libp2p-streams on HTTP connections, I think it can do the opposite too (http connections over libp2p-streams, like this library). In general it is confusing to me and I might be wrong, but just so you know.