Skip to content

Commit 29eb251

Browse files
committed
polishes WebSocketTransport.cs; fixes subprotocol passing
1 parent 9a9975f commit 29eb251

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

RSocket.Core/Transports/WebSocketTransport.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,13 @@ public async Task<WebSocket> AcceptWebSocketAsync(string subprotocol, IDictionar
8787
{
8888
socket.Options.SetRequestHeader(key, headers[key]);
8989
}
90-
socket.Options.KeepAliveInterval = new TimeSpan(1, 1, 1);
91-
try
92-
{
93-
await socket.ConnectAsync(Transport.Url, Cancel);
94-
}
95-
catch (Exception e)
90+
91+
if (subprotocol != null)
9692
{
93+
socket.Options.AddSubProtocol(subprotocol);
9794
}
95+
96+
await socket.ConnectAsync(Transport.Url, Cancel);
9897
return socket;
9998
}
10099
}
@@ -155,7 +154,7 @@ public async Task ProcessRequestAsync(HttpContext context, CancellationToken tok
155154
Debug.Assert(context.WebSockets.IsWebSocketRequest, "Not a websocket request");
156155

157156
var subProtocol = _options.SubProtocolSelector?.Invoke(context.WebSockets.WebSocketRequestedProtocols);
158-
IDictionary<string, string> headers = _options.Headers != null ? _options.Headers() : new Dictionary<string, string>();
157+
var headers = _options.Headers != null ? _options.Headers() : new Dictionary<string, string>();
159158
using (var ws = await context.WebSockets.AcceptWebSocketAsync(subProtocol, headers))
160159
{
161160
Log.SocketOpened(_logger, subProtocol);

0 commit comments

Comments
 (0)