Skip to content

Commit

Permalink
Improve transporter sample error (#1127)
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesNK authored Nov 30, 2020
1 parent 850f455 commit dfd2cb3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
21 changes: 3 additions & 18 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,24 +230,9 @@ This example uses [tye](https://github.com/dotnet/tye) to run the solution and f

## [Transporter](./Transporter)

**.NET 5 or later required**

The transporter example shows how to use gRPC over non-TCP transports. This example uses a [Unix domain socket (UDS)](https://en.wikipedia.org/wiki/Unix_domain_socket) to send gRPC messages between the client and server.

To use gRPC with UDS:

1. The client creates a channel with a custom SocketsConnectionFactory. The factory connects to a specified UDS endpoint.
2. The server configures a UDS endpoint with [KestrelServerOptions.ListenUnixSocket](https://docs.microsoft.com/dotnet/api/microsoft.aspnetcore.server.kestrel.core.kestrelserveroptions.listenunixsocket) in *Program.cs*.

##### Scenarios:

* Unix domain sockets
* SocketsConnectionFactory
* [KestrelServerOptions.ListenUnixSocket](https://docs.microsoft.com/dotnet/api/microsoft.aspnetcore.server.kestrel.core.kestrelserveroptions.listenunixsocket)

## [Transporter](./Transporter)

**.NET 5 or later required**
**Requirements:**
* .NET 5 or later
* Linux, MacOS or a [modern version of Windows](https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/)

The transporter example shows how to use gRPC over non-TCP transports. This example uses a [Unix domain socket (UDS)](https://en.wikipedia.org/wiki/Unix_domain_socket) to send gRPC messages between the client and server.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#endregion

using System;
using System.IO;
using System.Net;
using System.Net.Http;
Expand Down Expand Up @@ -43,10 +44,10 @@ public async ValueTask<Stream> ConnectAsync(SocketsHttpConnectionContext _, Canc
await socket.ConnectAsync(_endPoint, cancellationToken).ConfigureAwait(false);
return new NetworkStream(socket, true);
}
catch
catch (Exception ex)
{
socket.Dispose();
throw;
throw new HttpRequestException($"Error connecting to '{_endPoint}'.", ex);
}
}
}
Expand Down

0 comments on commit dfd2cb3

Please sign in to comment.