ipfs / go-graphsync

Initial Implementation Of GraphSync Wire Protocol
Other
100 stars 38 forks source link

Interface to register listeners for network errors on receiving side #129

Closed dirkmc closed 3 years ago

dirkmc commented 3 years ago

Currently there is a RegisterNetworkErrorListener to listen for errors that occur when sending a request. It would be useful to also be able to listen for errors that occur while processing a stream on the receiving side. Suggested name: RegisterReceiverNetworkErrorListener

Motivation

When a client wants to send data to a provider

  1. go-data-transfer client opens a "push" channel to the provider
  2. go-data-transfer provider opens a go-graphsync query to the client for the file
  3. go-graphsync responds with the file data

If there is a network error (eg if the provider is restarted), the provider should wait for the client to restart the "push" channel. The client can begin attempting to restart the channel as soon as graphsync reports a network error.

Needed for Miner should not try to dial the client to restart a data transfer

Implementation proposal

Currently when there is a network error on the receiving side, the networking layer calls ReceiveError(err). ReceiveError could use a pubsub mechanism to call the listeners, or the networking layer could do that directly.

Ideally the listener would take two parameters: func(peer.ID, error)

hannahhoward commented 3 years ago

@dirkmc we can certainly propogate the errors in ReceiveError -- I don't know what it will actually communicate. I believe ReceiverError is only called when we attempt to decode a protobuf message from the stream and error. Seems to come up mostly around connection resets? Hard to know.

Anyway, I can definitely address this -- it's not a hard ticket, but I'm not sure whether it will solve whatever problem you're attempting to solve.

dirkmc commented 3 years ago

@hannahhoward in my testing, when I restart the Provider, on the client side I see the log message Graphsync ReceiveError: io: read/write on closed pipe This is coming from ReceiveError.

It would be useful for the client to be informed of this error so that it can attempt to reconnect to the Provider.